我正在尝试在C#中编写一个项目Windows服务。将DirectoryInfo转换为Windows服务中的字符串
我想将文件夹复制到另一个目录。我写的代码,一切都是完美的
DirectoryInfo source = new DirectoryInfo("C:\\belgeler");
DirectoryInfo target = new DirectoryInfo("E:\\Backup");
这是正确执行,但是当我写这篇文章...
DirectoryInfo source = new DirectoryInfo(from_path);
DirectoryInfo target = new DirectoryInfo(to_path);
的错误是“A字段初始不能引用非静态 字段,方法或属性 'BACKUP(myproject_name).Service1.veri'
//string to_path = Registry.LocalMachine.GetValue("ToPath").ToString();
//string from_path = Registry.LocalMachine.GetValue("FromPath").ToString();
此代码块正在工作控制台应用程序,但在Windows服务中不是。
它是一个非静态的字段,方法或属性吗? ;) –
“此代码块正在工作控制台应用程序,但在Windows服务中不是。”它是COMPILING作为一个控制台应用程序,但不是一个Windows服务?我非常怀疑...... – aquinas
是你的类的'from_path'和'to_path'成员,还是它们是局部变量?那么'source'或'target'呢? –