Solved

Access Denied with Process.start when reading a text file.

Posted on 2010-08-27
10
508 Views
Last Modified: 2012-05-10
I'm trying to open a log file from an applications, I'm using the native listview control in vb.net in teh dblclick event the file path and name is correctly found, but when feeding to the start process function I get an 'Access is denied' error, any ideas?  The value of the file/path is i.e.

LogFilePaht = F:\Software Source Code\Virtual Web Software\Charlotte Burn Permit\bin\Debug\log_files\bp-8-24-2010.log

    Private Sub LogFileList_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LogFileList.DoubleClick
        Dim LogFilePath As String = LogFileList.SelectedItems(0).ToString
        System.Diagnostics.Process.Start(LogFilePath)
    End Sub

Open in new window


.log is associated with a valid applications.
0
Comment
Question by:DRRobinson
  • 5
  • 4
10 Comments
 
LVL 17

Expert Comment

by:Zhaolai
Comment Utility
It looks like a permission issue.
Can you open that file from your Windows Explorer? Or Press Start->Run, copy/paste the file path/name in the box and hit OK. See if the file opens up.

0
 

Author Comment

by:DRRobinson
Comment Utility
I don't think it's a permission issue.  I'm able to open the file just fine, and I was using a thrid party list box for the same function,but opted for the viewlist control that's native to VB.net so I would not have to distribute any third party contorls..
0
 
LVL 17

Expert Comment

by:Zhaolai
Comment Utility
Or try this:

System.Diagnostics.Process.Start("Notepad.exe", LogFilePath)
0
 
LVL 5

Expert Comment

by:jijeesh
Comment Utility
What type of application you have this code?? Is it from a web application or a windows forms app?
If it is from ASP.NET page, you should grant enough permission to the ASP.NET user to the folder where you have file.
0
 

Author Comment

by:DRRobinson
Comment Utility
It's a windows form app.  As mentioned it was working great when I used a third  pary list control, but when I switched to the native listview control I'm getting the error. when using the syntax:

System.Diagnostics.Process.Start("Notepad.exe", LogFilePath) does not work.

but I belive the syntax sould be

System.Diagnostics.Process.Start("Notepad.exe" -F LogFilePath)

Which does not work either...
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 17

Expert Comment

by:Zhaolai
Comment Utility
Add Chr(34) to LogFilePath, like this:

System.Diagnostics.Process.Start(Chr(34) & LogFilePath & Chr(34))

because there are spaces in the path.


0
 

Author Comment

by:DRRobinson
Comment Utility
System.Diagnostics.Process.Start(Chr(34) & LogFilePath & Chr(34))

produces the error

No application is associated with the specified file for this operation - which is actually what I'm trying to do, I want to open the file in the program that is associated with the extension .log - in my case, it's not notepad, but ultraedit.
0
 
LVL 17

Expert Comment

by:Zhaolai
Comment Utility
One step closer...
You can either add association of the file type ".LOG" with ultraedit in Windows Explorer using Tools->Folder Options->File Type, add ".LOG" extension and Change to ultraedit in the "Open with",
or you need add ultraedit's full path in the code, like this:

System.Diagnostics.Process.Start(Chr(34) & "ultraedit Full Path" & chr(34), Chr(34) & LogFilePath & Chr(34))
0
 

Author Comment

by:DRRobinson
Comment Utility
Not sure what the deal was, but I just changed the listview to a regular list box and it is now working.  I think that perhaps there was a comfilict with variable naming.  I have a global variable named 'LogFilePath', then I was using  a local variable:

Dim LogFilePath As String = LogFileList.SelectedItems(0).ToString

instead of creating a new object from the form (Dim fLog as new frmSelLog), which is what I normally do, I just opened the frmSelLog as .showdialog. Not sure, but it's working now.. not sure how to finalize this thread?
0
 
LVL 17

Accepted Solution

by:
Zhaolai earned 500 total points
Comment Utility
Aha... I missed that part too. In listview, you should use this:
        Dim LogFilePath As String = LogFileList.SelectedItems(0).Text.ToString

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now