Solved

VB.Net Why doesnt this code work from the command line

Posted on 2013-06-14
4
403 Views
Last Modified: 2013-06-14
Hi Experts.   I'm testing some code in both a forms application and console application.  The code is this in the console or the same placed in the form load in the forms application.
 
Sub Main()
        Try
            My.Computer.FileSystem.WriteAllText("Test.txt", "Text,", True)
            MsgBox("")
            My.Computer.FileSystem.WriteAllText("Test2.txt", "Text,", True)
            End
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

If I go to the Release folder and double click either program it works correctly and the files are created in the Release Folder.

If I run either program from the command line, the messagebox appears but the files are not created.  

Please can someone explain why?

Thanks for the help.
0
Comment
Question by:PNRT
  • 2
4 Comments
 
LVL 11

Expert Comment

by:Paul S
ID: 39248774
try using an alternate name space for the same actions.

File Class (System.IO)
http://msdn.microsoft.com/en-us/library/system.io.file.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

it could be a problem with the my.computer name space.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39248965
Where are you running the console application from? You haven't specified an absolute path, so the file "Test.txt" is being written to the working directory of the console window.
0
 
LVL 2

Author Comment

by:PNRT
ID: 39248968
No luck Im afraid, tried different types including just creating the file.  All work when you doubleclick the file but nothing works when run from the command line
0
 
LVL 2

Author Comment

by:PNRT
ID: 39248978
Absolutley right Kaufmed, was there when I specified the path
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multiple file Upload asp.net 2 36
Help with highlighting rows based on identical values in multiple columns 1 34
Visual Studio editor? 1 37
Saveas need to save a copy 16 26
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now