如何通过C#中的USB端口从PC连接的移动设备中复制文件

时间:2017-12-18 12:16:05

标签: c#

我正在尝试从Android手机中复制通过USB端口连接到PC的文件。 此代码适用于将文件从一个文件夹复制到PC中的另一个文件夹。但是,当我尝试从手机上复制时,它会显示" Path Not Found"消息框。 请帮我解决这个问题。

if (System.IO.Directory.Exists(@"This PC\M Hassan\Phone\Lec\Android\Mid"))
            {
                string[] files = System.IO.Directory.GetFiles(@"This PC\M Hassan\Phone\Lec\Android\Mid");

                // Copy the files and overwrite destination files if they already exist. 
                foreach (string s in files)
                {
                    // Use static Path methods to extract only the file name from the path.
                    fileName = System.IO.Path.GetFileName(s);
                    destFile = System.IO.Path.Combine(destFolder, fileName);
                    System.IO.File.Copy(s, destFile, true);
                }

                MessageBox.Show("Successfully Configured.", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            else
            {
                MessageBox.Show("Path Not Found.", "Field Required", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }

0 个答案:

没有答案