现在我正在尝试截取屏幕截图并将其保存到本地计算机,然后将其复制到网络驱动器:
问:\1234567890123456789012345\123456789012\12345\截图\sc.jpg
^ 了解有多少个角色在说话。我已经设置为在“12345”之后创建一个屏幕截图文件夹当程序到达这一点时,会发生此错误:
我怎样才能避免这种情况?
还:
DirectoryInfo scdestinfo = new DirectoryInfo(scdest);
DirectoryInfo scinfo = new DirectoryInfo(sccpath);
CopyAll(scinfo, scdestinfo);
这是我复制文件夹/文件的代码。
public void CopyAll(DirectoryInfo source, DirectoryInfo target)
{
copyall = false;
try
{
//check if the target directory exists
if (Directory.Exists(target.FullName) == false)
{
Directory.CreateDirectory(target.FullName);
}//end if
//copy all the files into the new directory
foreach (FileInfo fi in source.GetFiles())
{
fi.CopyTo(Path.Combine(target.ToString(), fi.Name), true);
}//end foreach
//copy all the sub directories using recursion
foreach (DirectoryInfo diSourceDir in source.GetDirectories())
{
DirectoryInfo nextTargetDir = target.CreateSubdirectory(diSourceDir.Name);
CopyAll(diSourceDir, nextTargetDir);
}//end foreach
//success here
copyall = true;
}//end try
catch (IOException ie)
{
MessageBox.Show(ie.Message);
//handle it here
copyall = false;
}//end catch
}//end CopyAll
和copyall功能。