Thursday, July 30, 2009

What C# codes used for moving, copying, viewing and deleting a .txt file?

Using C# console application, how do you:


a. Copy .txt file to another location


b. Delete .txt file from source


c. Move .txt to another location


d. view string from the source of .txt file


d. Inform the user that the file location doesn't exist?





Thanks.

What C# codes used for moving, copying, viewing and deleting a .txt file?
%26gt; a. Copy .txt file to another location





System.IO.File.Copy(src, dst);





%26gt; b. Delete .txt file from source





System.IO.File.Delete(path);





%26gt; c. Move .txt to another location





System.IO.File.Move(src, dst);





%26gt; d. view string from the source of .txt file





using (StreamReader reader = new StreamReader(path))


while (!reader.EndOfStream)


Console.WriteLine(


reader.ReadLine());





%26gt; d. Inform the user that the file location doesn't exist?





if (!System.IO.File.Exists(path))


Console.WriteLine("The file doesn't exist!");





That's 5 questions, you owe me another 40 points :)


No comments:

Post a Comment