By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,934 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,934 IT Pros & Developers. It's quick & easy.

How to open a .txt file from ASP.NET

P: n/a
Hi group!!! I am new in the ASP.NET programming. I am trying to open a
..txt file but I can't do it.

I am using: but i don't know if its the right way. Thanks for help me.
Dim proc As New System.Diagnostics.Process

proc.Start(file:///C:/bitacora.txt)
Nov 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Here's a quick function to load the entire text file into a string.

private string LoadFile( string file )
{
string contents = "";
using(StreamReader sr = new StreamReader(file))
{
contents = sr.ReadToEnd();
}
return contents;
}

"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi group!!! I am new in the ASP.NET programming. I am trying to open a
.txt file but I can't do it.

I am using: but i don't know if its the right way. Thanks for help me.
Dim proc As New System.Diagnostics.Process

proc.Start(file:///C:/bitacora.txt)

Nov 18 '05 #2

P: n/a
Oh, and the format for calling the LoadFile function might be like:

string filesContents = LoadFile( "c:\\temp\\mytext.txt")

or like

string filesContents = LoadFile(@"c:\temp\mytext.txt") // in this example,
the @ sign automatically escapes the backslashes!

"ESPN Lover" <es**@lover.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
Here's a quick function to load the entire text file into a string.

private string LoadFile( string file )
{
string contents = "";
using(StreamReader sr = new StreamReader(file))
{
contents = sr.ReadToEnd();
}
return contents;
}

"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi group!!! I am new in the ASP.NET programming. I am trying to open a .txt file but I can't do it.

I am using: but i don't know if its the right way. Thanks for help me.
Dim proc As New System.Diagnostics.Process

proc.Start(file:///C:/bitacora.txt)


Nov 18 '05 #3

P: n/a
I think, I din't be clear with the question.

I want to open the .txt file within an aplication... like Notepad, Excel,
etc. Not just read it.

Thanks...

"ESPN Lover" <es**@lover.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
Here's a quick function to load the entire text file into a string.

private string LoadFile( string file )
{
string contents = "";
using(StreamReader sr = new StreamReader(file))
{
contents = sr.ReadToEnd();
}
return contents;
}

"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi group!!! I am new in the ASP.NET programming. I am trying to open a .txt file but I can't do it.

I am using: but i don't know if its the right way. Thanks for help me.
Dim proc As New System.Diagnostics.Process

proc.Start(file:///C:/bitacora.txt)


Nov 18 '05 #4

P: n/a
Where is the application going to be "run" on...client or server?

Once the .txt file is in notepad, what is going to happen to it?
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I think, I din't be clear with the question.

I want to open the .txt file within an aplication... like Notepad, Excel,
etc. Not just read it.

Thanks...

"ESPN Lover" <es**@lover.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
Here's a quick function to load the entire text file into a string.

private string LoadFile( string file )
{
string contents = "";
using(StreamReader sr = new StreamReader(file))
{
contents = sr.ReadToEnd();
}
return contents;
}

"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi group!!! I am new in the ASP.NET programming. I am trying to open
a
.txt file but I can't do it.

I am using: but i don't know if its the right way. Thanks for help

me. Dim proc As New System.Diagnostics.Process

proc.Start(file:///C:/bitacora.txt)



Nov 18 '05 #5

P: n/a
The application is going to be run on client. And I just want to show the
file on the notepad.

"ESPN Lover" <es**@lover.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
Where is the application going to be "run" on...client or server?

Once the .txt file is in notepad, what is going to happen to it?
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I think, I din't be clear with the question.

I want to open the .txt file within an aplication... like Notepad, Excel,
etc. Not just read it.

Thanks...

"ESPN Lover" <es**@lover.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
Here's a quick function to load the entire text file into a string.

private string LoadFile( string file )
{
string contents = "";
using(StreamReader sr = new StreamReader(file))
{
contents = sr.ReadToEnd();
}
return contents;
}

"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
> Hi group!!! I am new in the ASP.NET programming. I am trying to

open
a
> .txt file but I can't do it.
>
> I am using: but i don't know if its the right way. Thanks for help

me. > Dim proc As New System.Diagnostics.Process
>
> proc.Start(file:///C:/bitacora.txt)
>
>



Nov 18 '05 #6

P: n/a
Even though this seems easy, this is a really difficult task without the
end-user openning the application themselves since if you stream text down,
most browsers will display it as is. Plus, there's no known way to launch
applications on a client's machine via a web page. Who's to say they even
have the application on their computer? Even if they did, it'd be a big
security hole to allow a web page to launch programs on someone's machine.

Tell us what exactly is the requirements are, and there may be other ways to
handle this.
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
The application is going to be run on client. And I just want to show the file on the notepad.

"ESPN Lover" <es**@lover.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
Where is the application going to be "run" on...client or server?

Once the .txt file is in notepad, what is going to happen to it?
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I think, I din't be clear with the question.

I want to open the .txt file within an aplication... like Notepad, Excel, etc. Not just read it.

Thanks...

"ESPN Lover" <es**@lover.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
> Here's a quick function to load the entire text file into a string.
>
> private string LoadFile( string file )
> {
> string contents = "";
> using(StreamReader sr = new StreamReader(file))
> {
> contents = sr.ReadToEnd();
> }
> return contents;
> }
>
>
>
> "Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
> news:%2***************@TK2MSFTNGP09.phx.gbl...
> > Hi group!!! I am new in the ASP.NET programming. I am trying
to open
a
> > .txt file but I can't do it.
> >
> > I am using: but i don't know if its the right way. Thanks for
help me.
> > Dim proc As New System.Diagnostics.Process
> >
> > proc.Start(file:///C:/bitacora.txt)
> >
> >
>
>



Nov 18 '05 #7

P: n/a
Thanks, Now I understand that is difficult in that way, I'll try showing
the information in a container control.

Thanks again for your time.

"ESPN Lover" <es**@lover.com> wrote in message
news:O6**************@TK2MSFTNGP12.phx.gbl...
Even though this seems easy, this is a really difficult task without the
end-user openning the application themselves since if you stream text down, most browsers will display it as is. Plus, there's no known way to launch
applications on a client's machine via a web page. Who's to say they even
have the application on their computer? Even if they did, it'd be a big
security hole to allow a web page to launch programs on someone's machine.

Tell us what exactly is the requirements are, and there may be other ways to handle this.
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
The application is going to be run on client. And I just want to show

the
file on the notepad.

"ESPN Lover" <es**@lover.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
Where is the application going to be "run" on...client or server?

Once the .txt file is in notepad, what is going to happen to it?
"Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I think, I din't be clear with the question.
>
> I want to open the .txt file within an aplication... like Notepad,

Excel,
> etc. Not just read it.
>
> Thanks...
>
> "ESPN Lover" <es**@lover.com> wrote in message
> news:eN**************@TK2MSFTNGP11.phx.gbl...
> > Here's a quick function to load the entire text file into a string. > >
> > private string LoadFile( string file )
> > {
> > string contents = "";
> > using(StreamReader sr = new StreamReader(file))
> > {
> > contents = sr.ReadToEnd();
> > }
> > return contents;
> > }
> >
> >
> >
> > "Juan Manuel Alegría B." <jm*********@hotmail.com> wrote in message > > news:%2***************@TK2MSFTNGP09.phx.gbl...
> > > Hi group!!! I am new in the ASP.NET programming. I am trying to open
> a
> > > .txt file but I can't do it.
> > >
> > > I am using: but i don't know if its the right way. Thanks for help me.
> > > Dim proc As New System.Diagnostics.Process
> > >
> > > proc.Start(file:///C:/bitacora.txt)
> > >
> > >
> >
> >
>
>



Nov 18 '05 #8

P: n/a
Having an application on a client-side run is not impossible if you try to
use client script like the following;
'----------------------------------------------
<script language="vbscript">
Sub cmdExcel1_onclick()
set appXl = createobject("excel.application")
With appXl
.Workbooks.Add
.Worksheets.Add
End With

appXl.Visible = True
exlrowCnt = exlrowCnt + 1
appXl.cells.Font.Size = 10
appXl.Columns("A:A").Select
appXl.selection.ColumnWidth = 20
appXl.Columns("B:CZ").Select
appXl.selection.ColumnWidth = 5
appXl.Columns("B:B").Select
appXl.ActiveWindow.FreezePanes = True

appXl.cells(1,1) = 2394023034
End Sub
</script>

<input type=button value="get Excel" name="cmdExcel1">
'----------------------------------------------
the thing is when you try to write a data( calculated or managed by server)
on the client's application.
of course, this can be done by the function "RegisterClientScriptBlock()"
with the asp.net. (refer to the msdn about
"Page.RegisterClientScriptBlock()") thogh,
do i really have to concatenate string values and server-side value together?

i hope any one help me...

"ESPN Lover" wrote:
Even though this seems easy, this is a really difficult task without the
end-user openning the application themselves since if you stream text down,
most browsers will display it as is. Plus, there's no known way to launch
applications on a client's machine via a web page. Who's to say they even
have the application on their computer? Even if they did, it'd be a big
security hole to allow a web page to launch programs on someone's machine.

Tell us what exactly is the requirements are, and there may be other ways to
handle this.
"Juan Manuel AlegrÃ*a B." <jm*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
The application is going to be run on client. And I just want to show

the
file on the notepad.

"ESPN Lover" <es**@lover.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
Where is the application going to be "run" on...client or server?

Once the .txt file is in notepad, what is going to happen to it?
"Juan Manuel AlegrÃ*a B." <jm*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I think, I din't be clear with the question.
>
> I want to open the .txt file within an aplication... like Notepad,

Excel,
> etc. Not just read it.
>
> Thanks...
>
> "ESPN Lover" <es**@lover.com> wrote in message
> news:eN**************@TK2MSFTNGP11.phx.gbl...
> > Here's a quick function to load the entire text file into a string.
> >
> > private string LoadFile( string file )
> > {
> > string contents = "";
> > using(StreamReader sr = new StreamReader(file))
> > {
> > contents = sr.ReadToEnd();
> > }
> > return contents;
> > }
> >
> >
> >
> > "Juan Manuel AlegrÃ*a B." <jm*********@hotmail.com> wrote in message
> > news:%2***************@TK2MSFTNGP09.phx.gbl...
> > > Hi group!!! I am new in the ASP.NET programming. I am trying to open
> a
> > > .txt file but I can't do it.
> > >
> > > I am using: but i don't know if its the right way. Thanks for help me.
> > > Dim proc As New System.Diagnostics.Process
> > >
> > > proc.Start(file:///C:/bitacora.txt)
> > >
> > >
> >
> >
>
>



Nov 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.