473,395 Members | 1,484 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to write a file saving function, which checks if file already exists?

134 100+
Can somebody please tell me how to write a save function, which first is going to check if a name already exists in the file in which is must be saved? I am using streamreaders and writers.
If there are a lot of possible ways to do this, then please tell me the shortest way with an if, else statement.

If you also know a very easy way with an if, else statement with a streamwriter or reader to remove the string out of the file, then please help me.

Thanks in advance for the help.

P.S. Sorry if it is bad english but it's not my best language.
Feb 10 '11 #1
1 1829
GaryTexmo
1,501 Expert 1GB
http://msdn.microsoft.com/en-us/libr...le.exists.aspx

The File.Exists method in the System.IO namespace should be what you need.

As for how to save a file, I'm guessing you want text? You can read about that here:
http://www.csharp-station.com/HowTo/...eTextFile.aspx

:)
Feb 10 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: BadOmen | last post by:
I have a text file that I want to save from my program. But I don't want to save the empty lines. I want to delete everything after the last character, Is that possible? Then when I read the...
1
by: Aravindhan | last post by:
Hi.... I have created an Access form with a few text boxes,save and close button. The save button calls a function(funcSave) to collect data from the text boxes of the form and insert into a...
0
by: prakash | last post by:
Dear Friends I am new guy to Visual C++.NET I've program to save website as a image vc++.net . It have a function "SaveSnapshot" to save the webpage as an image On that function ifor saving...
2
by: AxOn | last post by:
How can I save the text from a rich text box that is generated as a new rich text box in a tab control? I want to be able to have several rich text boxes open, and save the one that is under the...
6
by: Ken Mylar | last post by:
I have a dilema here that I'm hoping some one can help me out with. On my forms I have some basic New, Edit, Save, Delete, Undo buttons on them. When first opened all controls on the form are not...
1
by: liuliuliu | last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image...
12
by: =?Utf-8?B?RnJlZU5FYXN5?= | last post by:
Hello, the scenario: There's an ASPX page which shows some text and has three buttons at the bottom: Save, Print and Close. Print and close is done by javascript. But how can I save the page...
4
by: stpark22 | last post by:
Hello, I've constructed a data entry form in Access 2003 that is bound to two related tables. A subform is embedded into the main form. I enter data for the parent table into the main form and...
5
by: xZaft | last post by:
def save(): try: saves.append(str(level)) saves.append(str(stre)) saves.append(str(spd)) saves.append(str(hp)) saves.append(str(maxhp)) ...
2
by: Ezzz | last post by:
I have dissabled the auto save function of my form, to prevent accidental editing by using:- Private Sub Form_BeforeUpdate(Cancel As Integer) If MsgBox("Changes have been made to the form. Are you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.