C#初学者使用file.creat()创建文件后,显示正由另一进程使用
2024-08-31 16:52:27
string sourcePhotoPath = this.GetUserSelectedPhoto();
if(sourcePhotoPath == null)
{
return;
}
string sourceFileName = System.IO.Path.GetFileName(sourcePhotoPath);
//把图片保存到文件夹
string userName = this.LoginUserName;
string newPath = @"Images";
if(!System.IO.Directory.Exists(newPath))
{
System.IO.Directory.CreateDirectory(newPath);
}
string destFile = userName + DateTime.Now.ToString("yyyyMMddHHMMss") + "_" + sourceFileName;
string destImgPath = System.IO.Path.Combine(newPath, destFile);
if(!File.Exists(destImgPath))
{
var myFile = File.Create(destImgPath);
myFile.Close();
}
FileInfo f1 = new FileInfo(sourcePhotoPath);
f1.CopyTo(destImgPath,true);
最新文章
- VS web项目 基于IIS调试和模拟域名调试
- nodejs学习笔记一——nodejs安装
- solr6.0.0 + tomcat8 配置问题
- webservice jsonp格式调用
- mac本用WTG(Windows To Go)安装Win10到移动硬盘
- BiliBili 第三方 Android 客户端应用源码
- 省略号 对单行 多行的css
- Android 自定义RecyclerView 实现真正的Gallery效果
- Using the Cordova Camera API
- codevs 1378选课 树形DP
- Entity Framework菜鸟初飞
- 【递推】BZOJ 4300:绝世好题
- 基于HTML5的SLG游戏开发(一):搭建开发环境(1)
- java中值类型与引用类型的关系
- OGG选择捕捉和应用模式
- 8、判断三角形ABC中是否有点D
- ngxs 状态管理器
- AngularJS 项目里使用echarts 2.0 实现地图功能
- Matlab 2016b 正式版下载
- Qwe中的数值结算
热门文章
- 紫书 习题 11-17 UVa 1670 (图论构造)
- 【codeforces 411B】Multi-core Processor
- inux 虚拟机桥接模式 静态ip设置,桥接才是王道
- 不安全的直接对象引用:你的 ASP.NET 应用数据是否安全?
- Centos7+httpd+fastcgi+rails安装
- angularjs ng-app
- jquery操作select的各种方法
- shell加法运算及i++
- Slimming Paint (a.k.a. Redesigning Painting and Compositing)
- python-排序算法 冒泡和快速排序