Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > reference to a script file
 

reference to a script file

I'm writing a windows form application in VS2008 using VB. I have a text script file needs to be deployed together with my application. How do I reference this file when coding and how to deploy it using windows installer? A similar question, how do I reference the installation folder of my application?

Sanping
Sanping Li  Monday, November 30, 2009 4:44 AM
just pack it up in the same folder where ur application is going to get deploy... and inside your application use TextReader to read the text file and implement what ever u need, if u want, u can even delete the file after u finish the process

here is he code to use TextReader
http://msdn.microsoft.com/en-us/library/system.io.textreader.aspx

hope this helps... let me know if u have any more queries


Narayanan Dayalan - Zeetaa Business Solutions ------- Please "Mark As Answer", if my answer works well with ur Query
Narayanan Dayalan  Monday, November 30, 2009 6:13 AM
Thanks for your reply. I'm new to VS. It appears I have made my question clear. For example, I have a script file "c:\App1\myBatch.bat", and in my application I need to do

Dim sh = CreateObject("WScript.Shell")

Dim ReturnCode = sh.Run("c:\App1\myBatch.bat" , 4, True)

If ReturnCode= 0 Then

do something...

End If

Currently I add the file "c:\App1\myBatch.bat" to my setup project using windows installer so the file will be installed somewhere like "C:/Programma Files/...", depending on the user's selection. You know the sh.Run line will not run on the user's machine. What's the solution?

Sanping

Sanping Li  Monday, November 30, 2009 7:32 AM
never worry about where the bat file is going to get placed, if the text bat file is been set to install in same folder where the application going to get installed...

if the text file is been placed in the same folder where the application is installed you can open the file by just

Dim ReturnCode = sh.Run("myBatch.bat" , 4, True)

hope this helps...


Narayanan Dayalan - Zeetaa Business Solutions ------- Please "Mark As Answer", if my answer works well with ur Query
Narayanan Dayalan  Monday, November 30, 2009 7:41 AM

Rather than using a setup project to delploy the file, add the text file to the main project through the solution explorer (right click the project and add an existing file). Then select the file and change its Copy to Ouput Directoryto Copy Always in the property grid. This will ensure that the text file is located in the same directory as the application. Then you can just use the filename without a path as Narayanan has suggested.


Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
Reed Kimble  Monday, November 30, 2009 4:25 PM
Thanks Narayanan and Reed, your suggestion works. However, I can't figure out the logic behind the method. The script file including the path is specified in a string variable, how does the system know where the file is? Is it because the application starts from the application folder so the system can "see" all the file under current folder? What if the current folder changes in runtime? If my guess is right, I think I need to store the current folder when the application starts and use it later. Am I right?

Sanping
Sanping Li  8 hours 1 minutes ago
if u specify a full path of script file and if it is not there then it will create a problem, but in our case we are just storing the script file in the same folder where the application is going to get installed, so never worry about the folders change and all, because your application is going to read the script from ur current application folder..

yes ur right, u need to store the script file in the same current folder of the application...

hope this helps....:-)



Narayanan Dayalan - Zeetaa Business Solutions ------- Please "Mark As Answer", if my answer works well with ur Query
Narayanan Dayalan  2 hours 55 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• How to convert to uppercase
• Why would vb.net fill to table adaptor from view be slow over ethernet (20 sec) but fast via activesync (1 sec)?
• Something's wrong with the bitmap.FromStream method --- can anybody help
• Create a game in VB 2008?
• How do I make text appear in another program
• How to update software over the web
• Generic method to return Structure
• how to add filter ?
• Mounting an image onto Windows
• Arrays vs. Collections