?
Solved

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

Posted on 2010-08-27
10
Medium Priority
?
536 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
ID: 33545240
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
ID: 33545306
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
ID: 33545319
Or try this:

System.Diagnostics.Process.Start("Notepad.exe", LogFilePath)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:jijeesh
ID: 33545739
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
ID: 33545827
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
 
LVL 17

Expert Comment

by:Zhaolai
ID: 33545877
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
ID: 33545950
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
ID: 33546078
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
ID: 33546226
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 2000 total points
ID: 33546283
Aha... I missed that part too. In listview, you should use this:
        Dim LogFilePath As String = LogFileList.SelectedItems(0).Text.ToString

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

850 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