We can find everywhere how to use an azure file share with the rest api, but I have a legacy .net app that uses System.File.IO for accessing a file share. How can I access the file share using System.File.IO ? These azure file share were created for supporting legacy app but I don't see the point if I have to rewrite all my file access code.
Asked
Active
Viewed 1,124 times
2 Answers
3
How can I access the file share using System.File.IO ?
You can amount Azure File share. After amounted the Azure File Share, you can access the share using System.File.IO through the mapped drive in the same Windows.
Mount an Azure File share and access the share in Windows
Otherwise, you can only access the file share using REST API or any client SDK. If you use .NET Framework, you could download and use Azure Storage .NET SDK.

Amor
- 8,325
- 2
- 19
- 21
-
The file share is mounted only for the current user right ? – remi bourgarel Aug 18 '17 at 08:23
-
So how do I execute this for an app which is run in IIS ? – remi bourgarel Aug 18 '17 at 08:54
-
If you did need to use the .NET File API, please take the way mentioned in following thread. https://stackoverflow.com/questions/35412669/access-mapped-drive-by-iis-running-asp-net-mvc-web-application/35466157#35466157 I tested it and worked fine on my side. Make sure that you access the files and folders by UNC path format only, just like the original poster have done in the thread. – Amor Aug 21 '17 at 05:45
-
See my answer, but your solution would only work for 1 account. I hae only one of those but for someone else it might be a problem. Thanks for your help. – remi bourgarel Aug 21 '17 at 11:46
3
I got the following solution, I run this at app start :
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo
{
FileName = "cmd.exe",
Arguments =
string.Format("net use * {0} /u:{1}", ConfigurationManager.ApplicationSettings("StaticServerRoot"), ConfigurationManager.ApplicationSettings("StaticServerRootCredentials"))
};
process.StartInfo = startInfo;
process.Start();
process.Kill();
Where StaticServerRootCredentials looks like this "AZURE\{account} {key}"
I could use cmdkey

remi bourgarel
- 9,231
- 4
- 40
- 73