No one knows how to use the File Class?
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngescalate' list.


Emir Kuc
-- This message, which was originally sent to "aspngstart", has been moved to "aspngescalate" mailing list by the List Master --

Ive sent this email once already, and it confuses me that no one has
replied to it. I would think that experienced .NET developers could
answer my query. So once again, im sending this email:

To whom - ever can help me :)

I would like to use the Open method from the File class which is
inherited from the System.IO. Ive had a look at the example, however i
am having trouble making it work.

I am new to the .NET framework and I would like someone to explain to me
what is meant by this:

public static FileStream Open(string, FileMode);

public static FileStream Open(
string path,
FileMode mode
);

How do i combine the Open method with the FileStream to make things
work?

Here is a FileStream example from .NET documentation, however i dont
understand how this FileStream example relates to the Open method in the
file class?

public static void Main(String[] args)
{
FileStream fs = new FileStream("log.txt", FileMode.OpenOrCreate,
FileAccess.Write);

StreamWriter w = new StreamWriter(fs);

w.BaseStream.Seek(0, SeekOrigin.End);
Log ("Test1", w);
Log ("Test2", w);

w.Close();

Can someone help me? Maybe theres a working example that someone can
paste for me, which uses the File.open method?

Reguards,
Emir.

---------------------------- ERG Group --------------------------
The contents of this email and any attachments are confidential
and may only be read by the intended recipient.
-----------------------------------------------------------------

| [aspngstart] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngstart.asp = JOIN/QUIT

---------------------------- ERG Group --------------------------
The contents of this email and any attachments are confidential
and may only be read by the intended recipient.
-----------------------------------------------------------------

Reply to this message...
 
    
Donny Mack
The code is almost exactly the same. The File.Open method returns a
FileStream. Here is a quick sample:

string FileName = Request.MapPath("filetoopen.txt");

FileStream fs = File.Open(FileName, FileMode.Open);

StreamReader SR = new StreamReader(fs);

while (SR.Peek() > -1) {

Response.Write(SR.ReadLine());

}

is this what you're looking for????

Donny Mack, MCSD
DotNetJunkies.com
________________________________________________
Site - dotnetjunkies.com/
Training - dotnetjunkies.com/training
Newsletter - dotnetjunkies.com/join.aspx
Books and Online Chapters - dotnetjunkies.com/dotnetbooks

Still not enough - Buy our book:
Programming Datadriven Web Applications with ASP.NET
by Donny Mack, Doug Seven
http://www.amazon.com/exec/obidos/ASIN/0672321068/dotnetjunkies-20/

-----Original Message-----
From: Emir Kuc [mailto:Click here to reveal e-mail address]
Sent: Sunday, July 22, 2001 10:00 PM
To: aspngescalate
Subject: [aspngescalate] No one knows how to use the File Class?

-- This message, which was originally sent to "aspngstart", has been moved
to "aspngescalate" mailing list by the List Master --

Ive sent this email once already, and it confuses me that no one has
replied to it. I would think that experienced .NET developers could
answer my query. So once again, im sending this email:

To whom - ever can help me :)

I would like to use the Open method from the File class which is
inherited from the System.IO. Ive had a look at the example, however i
am having trouble making it work.

I am new to the .NET framework and I would like someone to explain to me
what is meant by this:

public static FileStream Open(string, FileMode);

public static FileStream Open(
string path,
FileMode mode
);

How do i combine the Open method with the FileStream to make things
work?

Here is a FileStream example from .NET documentation, however i dont
understand how this FileStream example relates to the Open method in the
file class?

public static void Main(String[] args)
{
FileStream fs = new FileStream("log.txt", FileMode.OpenOrCreate,
FileAccess.Write);

StreamWriter w = new StreamWriter(fs);

w.BaseStream.Seek(0, SeekOrigin.End);
Log ("Test1", w);
Log ("Test2", w);

w.Close();

Can someone help me? Maybe theres a working example that someone can
paste for me, which uses the File.open method?

Reguards,
Emir.

---------------------------- ERG Group --------------------------
The contents of this email and any attachments are confidential
and may only be read by the intended recipient.
-----------------------------------------------------------------

| [aspngstart] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngstart.asp = JOIN/QUIT

---------------------------- ERG Group --------------------------
The contents of this email and any attachments are confidential
and may only be read by the intended recipient.
-----------------------------------------------------------------

| [aspngescalate] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngescalate.asp = JOIN/QUIT

Reply to this message...
 
 
System.IO.File
System.IO.FileAccess
System.IO.FileMode
System.IO.FileStream
System.IO.SeekOrigin
System.IO.StreamReader
System.IO.StreamWriter




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com