Quick code I made for filtering out extensions for my C# Uploader I'm making.
ExamplePHP Code:
static Boolean Evaluate_Extension(String Extension)
{
String[] Block = new String[] {".exe", ".html", ".php" };
if (Block.Contains(Extension))
{
return false;
}
return true;
}
PHP Code:
if(Evaluate_Extension(Path.GetExtension(@"C:\Users\Chad\Desktop\test.txt")) == true){
Console.WriteLine("Continue with process...");
}else{
Console.WriteLine("Inappropriate file!");
}
Results 1 to 4 of 4
Thread: [C#] Extension Filter
- 14 May. 2011 12:23am #1
[C#] Extension Filter
- 15 May. 2011 02:07pm #2
You may want to start using ternary operators for those simple true/false if statements. Those five lines can be shortened to:
PHP Code:return (Block.Contains(Extension)) ? false : true;
- 17 May. 2011 04:38am #3
- 24 May. 2011 02:21am #4
- Age
- 30
- Join Date
- Nov. 2009
- Location
- Anaheim, California
- Posts
- 1,065
- Reputation
- 99
- LCash
- 2.55