473,385 Members | 1,930 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,385 software developers and data experts.

File will not open after passing command line argument

The only code that is helpful is this:
fp = New IO.StreamReader(filename, New
System.Text.UnicodeEncoding(True, False), False)
If I pass a command line argument to my program that is not from Visual
Studio.NET is debug mode, the above code won't work, even though filename is
not changed whether I pass a command line argument or not. By not work, I
mean it will set fp.EndOfStream to true and fp.Peek() returns -1. The command
line argument is a file name, but not "filename" and is irrelevant. The file
is not concurrently open by any other program. Can someone please help me or
tell me how to work around what is probably is bug in VB.NET?
Aug 6 '07 #1
6 2336
Hi Forrest,

Does the code work if you run it in Visual Studio by setting the command
line arguments to the same filename in the Debug tab tot the Project
properties ?
Can you show the code that populates the filename variable ?

EG:

Sub Main(args() as String)
filename = args(0)

?

"Forrest Heller" <Forrest He****@discussions.microsoft.comwrote in message
news:E4**********************************@microsof t.com...
The only code that is helpful is this:
fp = New IO.StreamReader(filename, New
System.Text.UnicodeEncoding(True, False), False)
If I pass a command line argument to my program that is not from Visual
Studio.NET is debug mode, the above code won't work, even though filename
is
not changed whether I pass a command line argument or not. By not work, I
mean it will set fp.EndOfStream to true and fp.Peek() returns -1. The
command
line argument is a file name, but not "filename" and is irrelevant. The
file
is not concurrently open by any other program. Can someone please help me
or
tell me how to work around what is probably is bug in VB.NET?
Aug 6 '07 #2
Oh whoops: here is the code that gets the command line arguments:
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim i, cnt As Integer
'get cmd line params--for some reason they come with quotes (")
attached--guess this isn't Unix
Dim prog_args As String =
Microsoft.VisualBasic.Command().Replace("""", "")
Aug 6 '07 #3
Triple post. I feel terrible.
For full disclosure, here is all code executed in Mainform_load until the
get_configuration_list call

'failure to load config list?
Dim load_failure As Boolean = True
'let the DLL know the HWND
set_acoj_window(Me.Handle)
'set the parent of the reminder form to be me
rm.mparent = Me
'get configuration list
configurations = get_configurations(CONFIG_LIST_FILE)

Aug 6 '07 #4
As I said earlier, I'm lost on this code as it appears you are using a
constant, CONFIG_LIST_FILE, not the actual command line argument.

BTW: for the command line argument you can use
Environment.GetCommandLineArgs, . Index 0 is your exe, index 1 is the first
argument. ,eg.:
filename = Environment.GetCommandLineArgs(1)
That will avoid the need to remove any enclosing quotation marks.

"Forrest Heller" <Fo***********@discussions.microsoft.comwrote in message
news:CE**********************************@microsof t.com...
Triple post. I feel terrible.
For full disclosure, here is all code executed in Mainform_load until the
get_configuration_list call

'failure to load config list?
Dim load_failure As Boolean = True
'let the DLL know the HWND
set_acoj_window(Me.Handle)
'set the parent of the reminder form to be me
rm.mparent = Me
'get configuration list
configurations = get_configurations(CONFIG_LIST_FILE)
Aug 6 '07 #5
I changed the file path to an absolute one with Application.GetStartupPath
and that worked! I don't know why, though, because a file without a specified
path is searched for in the current directory, right? As long as it
works...Thanks for your help, Bill.
Aug 6 '07 #6
I'm not sure I was any, but I'm glad you got it working :)

"Forrest Heller" <Fo***********@discussions.microsoft.comwrote in message
news:62**********************************@microsof t.com...
>I changed the file path to an absolute one with Application.GetStartupPath
and that worked! I don't know why, though, because a file without a
specified
path is searched for in the current directory, right? As long as it
works...Thanks for your help, Bill.
Aug 6 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: se7en | last post by:
okay, i cant seem to run a file with another file as an argument. e.g I want to send the file "x.met" as an argument when running the file "y.py" thanx -python newbie-
79
by: pinkfloydhomer | last post by:
I want to scan a file byte for byte for occurences of the the four byte pattern 0x00000100. I've tried with this: # start import sys numChars = 0 startCode = 0 count = 0
1
by: raydelex | last post by:
I am new to securing a database with logins. My questions is: I want only one database to use a new Workgroup file that I have created, not all the Access databases that I bring up under my...
2
by: SunRise | last post by:
Hi I am creating a C Program , to extract only-Printable-characters from a file ( any type of file) and display them. OS: Windows-XP Ple help me to fix the Errors & Warnings and explain...
6
by: Bill English | last post by:
How do I associate file types with my application, and use its icon? Also is there an event I can use for when my application is loaded by opening those filetypes? Ex. Open a .rtf, and I want my...
8
by: Paul | last post by:
I have looked and looked for this info. All the I/O examples I've found either explicity use a file name or use the OpenFileDialog. When you drag a MS Word document over MS Word, it launches and...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
1
by: ohaqqi | last post by:
Hi guys, I'm still working on my shell. I'm trying to implement a function typefile that will take a command line input as follows: > type <file1> This command will implement a catenation of...
15
by: arnuld | last post by:
This is the partial-program i wrote, as usual, i ran into problems halfway: /* C++ Primer - 4/e * * Exercise 8.9 * STATEMENT: * write a function to open a file for input and then read...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.