我想將文件從Windows Mobile移動到Windows中的特定文件夾。移動設備中的文件位於「我的文檔」路徑中。 設備連接到WiFi網絡,並且在Windows中共享的文件夾被稱爲「文件夾」。如何將txt文件從Windows Mobile 6.5移動到Windows7
我怎麼能這樣做,我試過,但不起作用:
var f= System.Enviroment.GetFolderPath(System.Enviroment.SpecialFolder.Personal);
FileInfo fi = new FileInfo(f.ToString() + @"\file.txt");
fi.CopyTo(@"\\MYPERSONAL-PC\folder",true);
的錯誤是:
in System.IO.__Error.WinIOError(Int32 errorCode, String str)
in System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
in System.IO.FileInfo.CopyTo(String destFileName, Boolean overwrite)
in Project.MainForm.SaveButton_Click(Object sender, EventArgs e)
in System.Windows.Forms.Control.OnClick(EventArgs e)
in System.Windows.Forms.Button.OnClick(EventArgs e)
in System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
in System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
in Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
in System.Windows.Forms.Application.Run(Form fm)
in Project.Program.Main()
我還試圖用WNetAddConnection3,但仍與網絡資源的連接是一樣的,但總是返回相同的代碼在這裏:
兩[StructLayout(LayoutKind.Sequential)]
internal struct NetResource
{
public uint dwScope;
public uint dwType;
public uint dwDisplayType;
public uint dwUsage;
[MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
public string lpLocalName;
[MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
public string lpRemoteName;
[MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
public string lpComment;
[MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
public string lpProvider;
}
[DllImport("coredll.dll")]
private static extern int WNetAddConnection3(IntPtr hWndOwner,
ref NetResource lpNetResource, string lpPassword, string lpUserName, int dwFlags);
[DllImport("coredll.dll")]
static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool bForce);
var f= System.Enviroment.GetFolderPath(System.Enviroment.SpecialFolder.Personal);
NetResource logsResource = new NetResource();
logsResource.lpLocalName = "logs";
logsResource.lpRemoteName = @"\\MYPERSONAL-PC\folder";
logsResource.dwType = 0x1;
logsResource.dwScope = 0;
logsResource.dwUsage = 0;
logsResource.dwDisplayType = 0;
//try to connect the network resource
WNetAddConnection3(new IntPtr(0), ref logsResource, @"pass", @"dom\user", 0);
FileInfo fi = new FileInfo(f.ToString() + @"\file.txt");
**fi.CopyTo(@"\\MYPERSONAL-PC\folder", true);**
什麼不適用於此解決方案? –
返回我IOException,但我不知道爲什麼。 – puti26
這是什麼意思? –