I am trying to get the path for an xml file i created in my lightswitch application. however i am getting System.Security.SecurityException
error saying access is denied.
var fileNme = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"Sample.xml");
Debug.WriteLine("app data path " + fileNme.ToString());
I am running the application locally on my computer and the eventually deploy to iis. Hopefully someone solution can help me out here.
Thank you.
I am not an expert in LightSwitch, but you can try this:
Assembly asm = Assembly.GetAssembly(typeof(<<assemblyNamespace>>.<<name_of_page_class>>));
string asmPath = asm.CodeBase;
string app_DataFolder = Path.GetFullPath(Path.GetDirectoryName(asmPath.Remove(0, "file:\\\\\\".Length)) + "\\..\\App_Data");
string filePath = Path.Combine(app_DataFolder, "Sample.xml");
Hope it helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.