I currently have a Web Browser form published that in preview, I can use C# to create a .txt file of items in a repeating table and save to a mapped drive. Once published through Central Administration /Fully Trusted, I receive an error message when clicking the button that kicks off the code to access the local drive and write the .txt file to it. Are there any special permission that I have to have turned or do I need pass credentials to allow access to the local drive, which is not protected.
Here is my code:
// Setup array for data
string[] dbsFunctions = new string[tableRows.Count + 1];
int arrayPosition = 0;
string dbsID = root.SelectSingleNode("/my:myFields/my:dbsID", NamespaceManager).Value;
string userFuncNumber = root.SelectSingleNode("/my:myFields/my:userFuncNumber", NamespaceManager).Value;
// Loop through dbs repeating table and populate array with data
while (tableRows.MoveNext())
{
string value = tableRows.Current.SelectSingleNode("my:Function_Select", NamespaceManager).Value.ToString();
string dbsFunction = tableRows.Current.SelectSingleNode("my:Function_Name", NamespaceManager).Value.ToString();
string chkTrue = "True";
if (value == chkTrue)
{
dbsFunctions[arrayPosition] = "R" + dbsID + " " + dbsFunction;
arrayPosition += 1;
}
}
// Generate .txt file for dbs functions update
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"Z:" + userFuncNumber + ".txt"))
{
foreach (string line in dbsFunctions)
{
file.WriteLine(line);
}
}