移动MP3文件的问题 [英] Moving MP3 files problem

查看:81
本文介绍了移动MP3文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在那儿,我在将mp3文件移动到应用程序附近的目录时遇到问题,但是我收到了DirectoryNotFound异常,这里的代码是:

Hay there, I have a problem moving mp3 files to directory near the app but I get a DirectoryNotFound Exception here´s the code:

Synchronizer Sync = new Synchronizer();
                foreach(string file in OFD.FileNames)
                {
                    string path = @"";
                    path = OFD.FileName;
                    string name = @"";
                    name = OFD.SafeFileName;
                    Sync.MediaSync(path, name, true);
                }


触摸按钮时会发生这种情况

这是Synchronizer类的MediaSync方法:


THIS HAPPENS WHEN YOU TOUCH THE BUTTON

Here is the method MediaSync of Synchronizer class:

string Filepath = @"Music\" + file;
                if (!File.Exists(Filepath))
                {
                    File.Copy(path, Filepath); // I get the exception right here
                }
                else if (File.Exists(Filepath))
                {
                    File.Delete(Filepath);
                    File.Copy(path, Filepath);
                }



一些示例代码会很棒
谢谢



Some example code would be great
Thanks

推荐答案

使用调试器,检查源文件和目标文件路径是否正确.

您也可以使用 File.Copy方法(字符串,字符串,布尔值) [ ^ ]并将overwrite 设置为true
Using debugger, check that the source file and the destination file paths are correct.

Also you could simplify this by using File.Copy Method (String, String, Boolean)[^] and set the overwrite to true


这篇关于移动MP3文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆