I am trying not to delete internet shortcuts using c#
the code is like this

static void Main(string[] args)
            string path = @"C:\KOINA_ARXEIA";
            string[] folders;
            folders = System.IO.Directory.GetDirectories(path, "*", System.IO.SearchOption.AllDirectories);
            foreach (string folder in folders)
                Console.WriteLine("Getting files for Directory:{0}\n", folder);
                string[] files = System.IO.Directory.GetFiles(folder);

                foreach (string file in files)
                    string fileExtension = System.IO.Path.GetExtension(file);
                    if (fileExtension != ".url")
                        Console.WriteLine("File {0} is  url link, deleting it\n", file);

but they are deleted....the files are in greek words and url extension is not visible
I am using Windows Xp Sp3 pro

7 Years
Discussion Span
Last Post by DdoubleD

I don't understand. You say you are trying not to delete the files, but you are deleting: System.IO.File.Delete(file); .

When you say the url extension is not visible, what do you mean?


My bad syntax...sorry how not to delete.....I solved it......As u can see in my if statemt i use != to check wether something isn't an internet shortcut and if it's not...i delete it...But ok now...i retyped my if statement like this

if (System.IO.Path.GetExtesnion(file) != ".url") and worked like a charm....ty...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.