system.io.file创建
在实际开发中,如果用的文件名不能确定位置。或名字。可以使用GUID类来命名函数。Guid 结构标识全局唯一标示符。其NewGuid结构可以初始化一个新历。该方法语法格式如下:
public static Guid NewGuid();
return: 初始化后的实例。
源码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Drawing;
using System.Linq; using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication47
{ public partial class Form1 : Form
{ public Form1()
{ InitializeComponent(); }
private void button2_Click(object sender, EventArgs e)
{ FolderBrowserDialog p_folderbrowserdialog = new FolderBrowserDialog();
if(p_folderbrowserdialog .ShowDialog ()==DialogResult.OK )
{ File.Create(p_folderbrowserdialog.SelectedPath + "\\" + Guid.NewGuid().ToString() + ".txt"); } }
private void button1_Click(object sender, EventArgs e)
{ FolderBrowserDialog p_folderbrowserdialog = new FolderBrowserDialog();
if(p_folderbrowserdialog .ShowDialog ()==DialogResult.OK )
{ Directory.CreateDirectory(p_folderbrowserdialog.SelectedPath + "\\" + Guid.NewGuid().ToString()); } } } }
system.io.file创建的更多相关文章
- 详解C#中System.IO.File类和System.IO.FileInfo类的用法
System.IO.File类和System.IO.FileInfo类主要提供有关文件的各种操作,在使用时需要引用System.IO命名空间.下面通过程序实例来介绍其主要属性和方法. (1) 文件打开 ...
- System.IO.File类和System.IO.FileInfo类
1.System.IO.File类 ※文件create, copy,move,SetAttributes,open,exists ※由于File.Create方法默认向所有用户授予对新文件的完全读写. ...
- System.IO.File.Create 不会自动释放,一定要Dispose
这样会导致W3P进程一直占用这个文件 System.IO.File.Create(HttpContext.Current.Server.MapPath(strName)) 最好加上Dispose Sy ...
- IIS目录下文件共享后System.IO.File.Exists返回false
场景:在iis目录下,因为特殊需要共享一个文件夹,给到其他的技术人员访问,突然发现小小的操作,搞“大”了,使用 string path = Server.MapPath("~/file/te ...
- System.IO.File.WriteAllText("log.txt", "dddd");
System.IO.File.WriteAllText("log.txt", "dddd");
- 关于 System.IO.File.Exists 需要注意的事项
各位: .NET Framework 本省在设计的时候,他对于异常没有完全做到抛出,这样可能会有很多意想不到的问题. 比如 你在asp.net 应用程序中判断文件是否存在,这个文件可能是一个共 ...
- C# System.IO.File
using System; using System.IO; class Test { public static void Main() { string path = @"c:\temp ...
- 未处理的异常:system.io.file load exception:无法加载文件或程序集“ 。。。。 找到的程序集的清单定义与程序集引用不匹配。
问题描述: 添加控制器的时候,突然就报了这个错: Unhandled Exception: System.IO.FileLoadException: Could not load file or as ...
- 安卓上为什么不能用system.io.file读取streammingAssets目录下的文件
首先,看文档: Streaming Assets Most assets in Unity are combined into the project when it is built. Howe ...
随机推荐
- SQL Server MySQL 中的 in 与 null
例子: create table t(x int,y int); insert into t(x,y) values(1,1),(2,2),(null,null); 查询一: select x,y f ...
- 解决Qt程序发布时中文乱码问题(通过QApplication.addLibraryPath加载QTextCodec插件)
Qt程序的文字编码,是通过插件来解决的,所以我们发布的时候需要把相应的插件也发布出去,在开发者电脑上程序会自动从插件目录加载到插件,但是如果发布给别的电脑使用,需要手动指定插件路径,如下所示: int ...
- 鼠标进入与离开的消息(覆盖CM_MOUSEENTER与CM_MOUSELEAVE消息)——Windows本身没有这样的消息
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ...
- Unix/Linux环境C编程入门教程(11) 开发环境搭建VMWare虚拟安装之虚拟化检测
常开启虚拟化技术.如果你的主板是最新的,它在冷启动后能够检测到配置变化.每当我改变我的主板上的VT设置,它都会自动推迟下次重新启动生效.如何确定VT已经开启或禁用? 如图表示成功开启了VT. F10 ...
- 发布MFC ActiveX控件并实现自动更新
一. 引言 上一篇我们讲了如何使用 VC 2005来开发 MFC ActiveX控件,我们开发 ActiveX控件最终目的是将 ActiveX控件发布出来并嵌入在 Web网页中,随着控件 ...
- Loading Image
Android doesn’t handle animated gifs, but here’s one way to display an animated loading image that i ...
- OkHttp–支持SPDY协议的高效HTTP库
Android为我们提供了两种HTTP交互的方式: HttpURLConnection 和 Apache HTTP Client,虽然两者都支持HTTPS,流的上传和下载,配置超时,IPv6和连接池, ...
- 新辰:4G时代怎样利用手机进行移动APP营销?
未来的时代是4G时代,新辰手机用户的搜索量不在电脑端之下.那么,我们要怎样用手机进行营销呢?手机站点的竞价文章,要怎样去写比較好?手机站点要做专题吗?手机站点的优化思路在哪里?手机的系统不同,在不同的 ...
- ASPxGridview在对话框中无法编辑!!
aspxgridview在使用window.showModelDialog(或者window.showModelessDialog)打开的窗体中居然无法进入编辑!好奇怪啊 . 点击后显示“无法显示网 ...
- 用css控制一个DIV画图标。
在实际开发中,我们会用到一些小图形,图标.大多数情况下都是用图片来实现的,同时对图片进行处理使图片大小尽可能的缩小.但是图片在怎么处理也是按KB来算的.但是要是用CSS画,只要用很少的空间就能完成同样 ...