c# - 错误上传/下载文件到/从便携式设备使用
问题描述
我正在尝试无限循环地从 Android 三星平板电脑上传和下载文件。
示例代码是
while(true){
var devices = MediaDevice.GetDevices();
using (var device = devices.First())
{
device.Connect();
device.UploadFile(@"C:/Inbox/file.pdf", @"\Tablet\Inbox\file.pdf");
device.Disconnect();
}
System.Threading.Thread.Sleep(5000);
//I manually delete the file from folder before the next iteration
}//while
问题如下:在第一次迭代中,文件被上传,当我从平板电脑中物理删除文件(收件箱文件夹为空)并尝试再次上传文件时,我得到一个文件存在的异常,但是,平板电脑的收件箱文件夹为空。
下载文件时问题相同。在第一次迭代中,文件被下载,但是当在平板电脑上物理创建另一个文件时,则: device.EnumerateFiles(@"\Tablet\Outbox\"); 返回空列表。
我怎么解决这个问题?
解决方案
推荐阅读
- amazon-web-services - 无需登录即可访问api-gateway,然后创建帐户并进行授权
- python - Python Orator ORM 只通过 save 方法创建模型
- capl - 替代 CAPL 函数“TestWaitForDiagRequestSent”
- c++ - 作为模板类成员的模板类的特化
- c# - C# 同时支持 x64 和 x86
- php - 获取主键和外键匹配/不匹配的两个表的数据
- git - 拆分主存储库后同步管理存储库
- sql - 我的查询中没有索引(PostgreSQL)
- php - 在 Laravel 中区分 GET 和 POST 请求与路由
- python - 如何加快从压缩的 HDF5 文件中读取的速度