Overwrite a local file or delete it

1 Answer 114 Views
Fiddler Classic
Alex
Top achievements
Rank 1
Iron
Iron
Alex asked on 26 Oct 2022, 02:08 PM
I am using the 'File.AppendText' instruction to append data to a local file (in FiddlerScript).

Is there any way to clear the contents of the file before appending new data, such as overwriting the file or deleting it first? Is there any instruction for these tasks?

I just need to write data to a local file, and in case the file already exists, it should be overwritten.

Thank you!

Alex

1 Answer, 1 is accepted

Sort by
0
Nick Iliev
Telerik team
answered on 27 Oct 2022, 08:23 AM

Hi Alex,

 

You can use File.WriteAllText

File.WriteAllText Method

Creates a new file, write the contents to the file, and then closes the file. If the target file already exists, it is overwritten.

https://learn.microsoft.com/en-us/dotnet/api/system.io.file.writealltext?view=net-7.0 

 

Regards,
Nick Iliev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Alex
Top achievements
Rank 1
Iron
Iron
commented on 27 Oct 2022, 11:40 AM

Great, just what I needed, thank you!

Alex

Tags
Fiddler Classic
Asked by
Alex
Top achievements
Rank 1
Iron
Iron
Answers by
Nick Iliev
Telerik team
Share this question
or