473,385 Members | 1,901 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,385 software developers and data experts.

File Read and Write with C#

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
*-----------------------*
Nov 16 '05 #1
3 1241

"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in message
news:41********@Usenet.com...
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...b;en-us;304430

Hope these get you started.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 16 '05 #2
Thanks
how about second question?

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 16 '05 #3
//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
*-----------------------*
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: simon place | last post by:
is the code below meant to produce rubbish?, i had expected an exception. f=file('readme.txt','w') f.write(' ') f.read() ( PythonWin 2.3 (#46, Jul 29 2003, 18:54:32) on win32. ) I got...
3
by: Abhas | last post by:
> > Hi, this is Abhas, > > I had made a video library program in C++, but was facing a problem. > > After entering 12 movies, i cannot enter any more movies. > > Something gibberish comes instead....
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
8
by: a | last post by:
I have a struct to write to a file struct _structA{ long x; int y; float z; } struct _structA A; //file open write(fd,A,sizeof(_structA)); //file close
13
by: George | last post by:
Hi, I am re-writing part of my application using C#. This application starts another process which execute a "legacy" program. This legacy program writes to a log file and before it ends, it...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
1
by: shyaminf | last post by:
hi everybody! iam facing a problem with the transfer of file using servlet programming. i have a code for uploading a file. but i'm unable to execute it using tomcat5.5 server. kindly help me how to...
0
by: Craftkiller | last post by:
=========Program compiles on both windows and linux=========== Greetings, I am currently working on an encrpytion program that will take a file and a password string and flip the bits based on the...
15
by: patf | last post by:
Hi - experienced programmer but this is my first Python program. This URL will retrieve an excel spreadsheet containing (that day's) msci stock index returns. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.