Here's the situation, I have encrypted passwords in my employee database. I bring back the username, date changed, and the encrypted password.
I decrypt the passwords and put everything in a text file on the local machine.
Now all I want to do, is open the text file so the user can view the text document.
I'm using vb .Net 2002. The file name is C:\Passwords.doc
Can someone tell me the best way to open this file?
I tried shell and process.start but it won't seem to open.
ThanksDon't know if this is what you're after, but the following code will open a text file and output the contents to e.g. a Web Page:
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader(Server.MapPath("ForumsSnippets.txt"))
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Response.Write(line & "<br>")
Loop Until line Is Nothing
sr.Close()
YOu need to import the System.IO Namespace to access the StreamReader Class.
Perhaps I wasn't clear enough. I don't want to display this text file in the web page. There would be no formatting.
I want this file to opened by it's default program. For example, it is a .doc file so it would be opened by winword.
shell and process.start will open the file on the server, not on the client machine.
To make the file available for browsing, you need to open a virtual directory pointing to the directory where your files are generated (I hope you're not really storing stuff at the root of your hard disk). A simple hyperlink to the file (http://yourserver/thevirtualdirectory/passwords.doc) is enough for the file to open in Word.
Now, I also hope that you're not really storing unencrypted passwords into a file and that you don't really want to make this file available for browsing. I also hope that you're using the System.Cryptography stuff to encrypt, and not some homebrewed algorithm.
0 comments:
Post a Comment