Solved

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

Posted on 2010-08-27
10
525 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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 500 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

726 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