如何创建不存在的文件或使用文件流覆盖现有文件的方法 [英] how to create if not exist or overwrite existing file using filestream

查看:467
本文介绍了如何创建不存在的文件或使用文件流覆盖现有文件的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi ..

我正在使用文件流来创建pdf文件,我想要创建文件(如果尚不存在).如果已经存在,则应将其覆盖.

代码:
将Dim fs作为新FileStream(ReportFileName,FileMode.Create)

提供解决方案.

hi..

I am using filestream to create pdf file i want create file if it not already exist.if it already exist it should be overwritten.

code:
Dim fs As New FileStream(ReportFileName, FileMode.Create)

provide a soln thanx.

推荐答案

if (File.Exists(filename))
            {
                File.Delete(filename);
            }


if(File.Exists("path"))
       File.AppendAllText("path", "contents");


这篇关于如何创建不存在的文件或使用文件流覆盖现有文件的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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