?
Solved

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

Posted on 2010-08-27
10
Medium Priority
?
527 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 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