Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete all the text from a file?

Status
Not open for further replies.

meckeard

Programmer
Aug 17, 2001
619
US
How would I go about deleting some or all of the text in a file?

I am using a browser based WYSIWYG editor and I need to overwrite the existing text with the new text.

I know how to write to or append to the file. But this adds to the original text and I can't do this.

Ideally, I would like to delete all but the first line in the file, as it's actually a user control (.ascx) and I need the first line to stay. However, I can always grab it and rewrite it when I replace the original text.

Thanks.
 
you would probably be best to delete the file and recreate it with only the text you need.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
I tried, but I get the following error:

Exception Details: System.IO.IOException: The process cannot access the file "c:\inetpub\ because it is being used by another process.

This is an asp.net user control, so maybe that's the reason I get the error?!?
 
did you open the file in your developing environment (like in VS.NET) while the application was trying to delete it?

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top