Shell question

nvc944

Member
Joined
Apr 25, 2003
Messages
14
Ok guys I am working on a simple program

a command button that will find a file and rename it.
is there a simple way..

I was thinking of using the shell command but does not quite work the way I wanted to.

can someone please give me a quick code as I am sure this is very simple

thanks guys
 
You mentioned Shell command, do you want to start an external app? If so, try this...

Code:
    Dim WithEvents myP As Process

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        myP = Process.Start("c:\winnt\system32\notepad.exe")
        myP.EnableRaisingEvents = True
    End Sub

    Private Sub myP_Exited(ByVal sender As Object, ByVal e As System.EventArgs) Handles myP.Exited
        MessageBox.Show("Application Exited")
    End Sub

You can rename a file by making a copy then delete the original.

Code:
Dim f As System.IO.File
f.Copy("c:\Test.txt", "c:\testing.txt")
f.Delete("c:\Test.txt")
 
Code:
Dim sPath1 As String = "D:\file1.ext"
Dim sPath2 As String = "D:\file2.ext"

If File.Exists(sPath1) Then
    File.Move(sPath1, sPath2)
End If
 
hmm

Code works great but when I compile it and save it as an .exe it works on my main machine but not the others. is there a fix?
 
oh.. so how does one create..

oh.. so how does one create.. an application in .net and run it on other machines.. if they do not have that installed? might as well go vb6
 
VB6 requires runtimes too. If you want an application that doesnt require runtimes, use a language like C or C++.
 
C++ uses a runtime too just not very often

In 2008 Microsoft wont support VS6 casuing .Net to be the only choice anyway. The next version of Windows will probably have the .Net framework included.
 
C++ uses a runtime too just not very often
Microsofts Foundation Classes (MFC) are not C++ runtimes, and shouldnt be misconstrued as such. These classes are entirely optional, and are not required by any means.
 
Actually I was thinking of msvcp50.dll, msvcp60.dll, msvcp70.dll. They all contain the phrase: "Microsoft (R) C++ Runtime Library"
 
Originally posted by Robby
You mentioned Shell command, do you want to start an external app? If so, try this...

Code:
    Dim WithEvents myP As Process

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        myP = Process.Start("c:\winnt\system32\notepad.exe")
        myP.EnableRaisingEvents = True
    End Sub

    Private Sub myP_Exited(ByVal sender As Object, ByVal e As System.EventArgs) Handles myP.Exited
        MessageBox.Show("Application Exited")
    End Sub

You can rename a file by making a copy then delete the original.

Code:
Dim f As System.IO.File
f.Copy("c:\Test.txt", "c:\testing.txt")
f.Delete("c:\Test.txt")

Great was looking how to do this, only in c#. Pretty straightforward tho.
 
Back
Top