C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Delete text file file


Posted Date: 12 May 2008    Resource Type: Code Snippets    Category: C# Syntax

Posted By: Abhishek Arya       Member Level: Diamond
Rating:     Points: 10



This code sample shows how to create a text file, copy it and delete it.


using System;
using System.IO;

class Test
{
public static void Main()
{
string path = @"c:\temp\MyTest.txt";

using (StreamWriter sw = File.CreateText(path)) {}
string path2 = path + "temp";

// Ensure that the target does not exist.
File.Delete(path2);

// Copy the file.
File.Copy(path, path2);

// Delete the newly created file.
File.Delete(path2);
}
}


For more details, visit http://msdn.microsoft.com/en-us/library/system.io.file.delete.aspx




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Create an entry in the Eventlog
Previous Resource: Generics--- Using IEnumerable and yield
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

web conferencing

Contact Us    Privacy Policy    Terms Of Use