当我手动调试时,我的WCF服务工作正常,但是当我在IIS中托管相同的服务时,将托管服务的链接添加到我的Web应用程序然后服务被执行但是它没有创建我的文件想。这是我的WCF服务代码。
public void Deploy(string clientName)
{
string folderpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\" + "WCFFilesForIISHosting" + "\\";
if (!Directory.Exists(folderpath))
{
Directory.CreateDirectory(folderpath);
}
DirectoryInfo di = new DirectoryInfo(folderpath);
FileInfo[] files = di.GetFiles("*.txt").Where(p => p.Extension == ".txt").ToArray();
TextWriter tw;
string text = clientName;
string path = folderpath + "Clients" + ".txt";
if (!File.Exists(path))
{
File.Create(path).Dispose();
tw = new StreamWriter(path);
tw.WriteLine(text.ToString()+Environment.NewLine);
tw.Close();
}
else
{
File.AppendAllText(path, text.ToString()+Environment.NewLine);
}
}