MC Fer MC Fer - 1 year ago 75
C# Question

Error saving a file on server

I am generating a Key and i need to record on server. When i tried locally, it Works ! The problem is when i try on the server...
The archive is generated but when ON THE SERVER the download finish,but i cannot open and cannot save. I donĀ“t get an error...but i just cannot save...

The code:

string fileNamePrivate = @"pasta1/archive.txt";
StreamWriter textWriterPriv = new StreamWriter(fileNamePrivate, true);
var pemWriter = new PemWriter(textWriterPriv);

Answer Source

Try to use

string fileNamePrivate = "~/PASTA1/archive.txt";
StreamWriter textWriterPriv = new StreamWriter(fileNamePrivate, false);

How is a Server you have to use HostingEnvironment.MapPath and set "false" instead "true" on StreamWriter if you need to overwrite.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download