Jak przekazać poświadczenia podczas zapisywania pliku na ścieżce serwera?

Chciałbym napisać plik na ścieżce serwera, ale kiedy próbowałem to zrobić, otrzymaliśmy wyjątek, że nie mamy na to pozwolenia. Mamy identyfikator aplikacji i hasło, które ma uprawnienia do pisania na ścieżce serwera, ale nie wiem, jak mogę przekazać te poświadczenia:

Mój obecny kod:

<code>//Create a new GUID, extract the extension and create a new unique filename
string strFileGUID = System.Guid.NewGuid().ToString();
string extension = Path.GetExtension(attachment.AttachmentFileName);
string tempfilename = strFileGUID  + extension;  

string path = "ServerPath";

//Open a filestream and write the contents of the file at server path
FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write );
fs.Write(fileContent.Content, 0, fileContent.Content.Length);
fs.Flush();
fs.Close();
</code>

questionAnswers(1)

yourAnswerToTheQuestion