File Read and Write with C#

  • Thread starter Thread starter Dakkar
  • Start date Start date
D

Dakkar

I have 2 questions
first one is
How can i read from and write to files with c#
and the second one is
i want to write to a file which is in directory that i have in a
variable like
String path = "C:\Ultima Online\game\uo.exe";
and i want to drop the last part which comes after last \
is there anyway to do this?
Thanks

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Dakkar said:
I have 2 questions
first one is
How can i read from and write to files with c#
and the second one is
i want to write to a file which is in directory that i have in a
variable like
String path = "C:\Ultima Online\game\uo.exe";
and i want to drop the last part which comes after last \
is there anyway to do this?
Thanks

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

If you are using Visual Studio, I suggest you start with the MSDN Help
article entitled "Basic File I/O" which introduces the classes which support
the title functions. There are numerous links from that article to specifics
and examples.
Whether or not your are using Visual Studio, good alternate sources of
information can be found here:

http://www.codeproject.com/
http://support.microsoft.com/default.aspx?scid=kb;en-us;304430

Hope these get you started.
 
//prints c:\doc
Debug.WriteLine ( Path.GetDirectoryName ( @"c:\doc\test.doc" ) );

This will remove the filename.ext from the complete path string.
You may need to append the trailing backslash, as it is removed.

Hope that helps,
Joe

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top