Reputation: 21
I am facing a problem when running .net app on Azure. When using CreateDirectory method, it throws FileNotFoundException with the message of "Could not find file 'D:\home\site\wwwroot\CVs'.".
The app worked without any exception when running locally and on a private server. Any idea what could be the problem?
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "CVs"));
Upvotes: 2
Views: 1840
Reputation: 337
Assuming, that you're running your app as an Azure Web App, you need to be careful what you try to write to the file system, because of the nature of how the virtual machines of Azure Web Apps are handled.
Since Azure doesn't guarantee the availability of the same VM each time, but only the availability of a VM running your app, this means the file system (beyond the app files you deployed) isn't guaranteed to persist. If your app is scaled, then we're entering a whole new problem of persistence between multiple VMs.
Check the answer to the following question for more details: https://stackoverflow.com/a/12968226/912268
Upvotes: 2