473,320 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Program fails to write out its log file

!NoItAll
297 100+
I have written a program that logs errors it encounters. The logging mechanism is very simple. In a try/catch block I gather up the error message(s) into lines in a list. Loglines is a New List(Of String).

The LogFilename is generated as follows:

Expand|Select|Wrap|Line Numbers
  1. Dim LogFileName as String = Path.Combine(My.Application.Info.DirectoryPath, "MyLogFile.log")
  2.  
So I should be writing the log file in the same folder as the exe.

Then I write out the lines with

Expand|Select|Wrap|Line Numbers
  1. IO.File.WriteAllLines(LogFileName, LogLines)
On my system it runs fine and the log file is there. On an end users system no log file ever appears, even though it is catching errors.
Could this be an issue where the exe needs to be run as an administrator?

Perhaps my.application.info.directorypath is returning something bogus on the end-users sysem...?
Mar 21 '16 #1

✓ answered by !NoItAll

So I did find that, unless the program is being run as an administrator, then it will not have write permission. Unfortunately I get no errors because of the way I was trapping errors.
I modified the code to do a test write to the folder inside a try/catch block and then warn the user that the application needs to run as an administrator. I will work on my installer logic to get the program installed to run as an administrator (if that's even possible).

3 2891
Luk3r
300 256MB
You could just make the end user the owner with full control over the folder that the application is being run from. I tested that method and was able to reproduce your exact situation.
Mar 21 '16 #2
!NoItAll
297 100+
Thanks Luk3r!
Do I do that in my code, or installer? This is a commercial program so I don't have individual access to users machines.
Mar 21 '16 #3
!NoItAll
297 100+
So I did find that, unless the program is being run as an administrator, then it will not have write permission. Unfortunately I get no errors because of the way I was trapping errors.
I modified the code to do a test write to the folder inside a try/catch block and then warn the user that the application needs to run as an administrator. I will work on my installer logic to get the program installed to run as an administrator (if that's even possible).
Mar 24 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: chmod000 | last post by:
Hello, I'm trying to use the exec() call in php to run a program that I've written and compiled from C. This program attempts to create a new file and write data into it. If I simply run the...
2
by: Brent W. Hughes | last post by:
I'm just starting to learn pygame. I write what I think is just about the simplest program that should display a window and then quit. #----------------------------------------------- import sys...
6
by: Cyril Vi?ville | last post by:
As it's written in the subject, i would like to know how can i find which program modified a file (last access, last changed). By example: Example.txt in a log directory I need to know which...
1
by: Phil396 | last post by:
I have to create a simple program but I want it to look as professional as possible. The program needs to open a file on a network share write the contents of a number of files to one file. The...
2
by: cj | last post by:
I want when someone clicks the X in the upper right corner of my program for it to run the sub I've put in for the exit item on the main menu (exitMenuItem_click)
5
by: sjayaramit | last post by:
hello friends, Is it possible to run a C program from a batch file. I use Dev c/c++ compiler and store the program in devc++/programs/examples/myprogram/one.c
16
by: Hans Fredrik Nordhaug | last post by:
I'm trying to write to a file in the current directory - no remote files. The subject says it all - I can add that both the directory and the file is wordwritable. This happens on a (quite good)...
0
by: Swan | last post by:
Can anyone plz tell me,Can I write file on server using binary access,or it is only to write on local?(Actually I am creating OCX for Http File Upload Control in VB using API's.So for that I need to...
1
by: zak200 | last post by:
Hi, I compile my code and i got some error. I want to store the error message in a file. For example right now i am getting following error: D:\Zulfi\PERL MAIN FOLDER>perl...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.