Create an EXE that has files in it - vb.net

I want to create an Exe that copies files to a directory on the c drive.
So I want it to this.
I have added the files to the project.
And when I run the code. It copies the file.
My.Computer.FileSystem.CreateDirectory("C:\direcotory1")
My.Computer.FileSystem.CopyFile("file1", "c:\direcotry1\file1.dat")
The above code works, but...
After I compile if I move the exe out of the source directory, it doesn't work. I have to leave the exe in the directory where the file is.
Phrased another way. IF the exe is not in the directory it gets compiled into by Visual Studio. Then it cannot find the file to copy.
I know people do this all the time, but I am not sure how to get them in there.
Properties are set to content, or embedded resource don't seem to make a difference.
Can anyone give me the piece I am missing?
Thanks
Dan

Related

Visual Basic 2010, finishing your project by getting the exe file from bin, or publishing

ok so i made a couple of projects in VB2010 and i want to finally make them a standalone executable , as i'm still a beginner in VB ! i don't know if getting the .exe file only from "bin/debug" or i should really publish it then need the applications folder and the setup [because it's gonna be a lot better if i don't have to do the second one], anyways i tried to get the exe file then move the project folder to another drive , and it work , i know that to run the exe in other computer i'll need framework , [as far as i know my resource files are embedded into the exe] but if i need framework only , i guess runing it on computers that doesn't have it will ask them to download it ! i don't mind that , or that option comes with publish ,and i also really need the manifest file to run it normally ,
I actually don't know much about this so can you pleas tell me what i exactly need so my .exe files can run on other computers
sorry for taking some of your time , and thank you for reading this :D
Set your Solution Configurations to Release, build a solution (Ctrl+Shift+B) then navigate to your bin/Release folder and there you will find your exe file ready to be shipped. You can ship that exe as is, or you can wrapp it up in an installer application. If your application has some dependencies then shipping the exe file will not be enough.
You can change your target framework by goin' to Project/Properties.
Find the .exe in \\Your app\bin\debug\your app.exe
What you can do,open the project as if going to edit it, just go to "Project" then "Publish(Whatever-your-work's-name-is).vb at the bottom. Then use the wizard to finish. At the end, say you saved your exe on the desktop, three files will appear.
"Whatever-your-work's-name-is".exe And its icon shape varies.
A folder called "Application Files"
And a "setup.exe" Its icon a like a CD on something.
For the first time, click on setup.exe and open the app. From then on, the "Whatever-your-work's-name-is".exe will open normally. I have a website where I publish these things for fun, "tgamer.myfreesites.net", and downloading will only download all three in a zipped folder. The website is not awesome, but it's alright.
The thing is, the setup.exe and application files can be in a zipped file. You only the actual exe from the second opening and onward. This option makes it downloadable, like what I want. For you, choose the best for you, but remember downloading only the exe will not work.

Remove the PDB file/functionality from Lib

I'm stuck in the following situation, I have been asked to rebuild a website, the original site was built and the solution had 5 projects, 4 of these where the different data layers and one of them was the actual website.
I only have the dll's of the 4 projects, so far I've managed to rebuild the website and adding the dll's to my project gives me access to the Entities and Repository layer etc... everything builds fine.
The problem is that when I run the project the debugger is trying to look for the Source files of the dll's that I've added which I don't have. Is there a way to remove the PDB file/functionality from the dll's that I've added? I don't need to or want to debug those dll's as I know that they are working correctly... and I dont have the code to change them if they arent.
Or to ask it in another way, is there a way to add them to my project and force them to not run with the Debugger?
Thanks
Ok, so to solve this problem I had to decompile the lib's of the four projects, create and place the code files in the exact directory that is specified in the PDB files and then compile and run the website.
I dont think it cared that the source files didn't compile again, it just needed to know that they where there.
After running the site i could delete the created path and source files and I haven't had a problem since.

Include and Call PDF File in vb.net (after Deployement)

Glad to see this site, Thanks guys for being active. :)
I have a problem in Visual Studio 2010/VB.Net
I have windows form in Visual Basic, I deployed the software(form) to one installer
Now I want to open My PDF file( i-e: Specific) with Button_Click_Event
I know that:
Process.Start("MyPDF.pdf")
But I dont know if user install my software in his PC so may be he install the software in C D or other directory, and also I dont know How to include PDF file in my project :)
Please suggest for me, I am searching this every where but failed so pl help me
Use Add->Existing Item on your Project. Then add the PDF File to your Project.
Afterwards you have to set the Properties of the newly added file to the following:
Now the file will be added to your "Output" Directory after you build your Project.
Now use your Process.Start("MyPDF.pdf") call. It will open up, as it resides in the same directory.
This is rather easy:
Simply include the file by dragging it to your project folder and in its options, tell it to copy to the build directory.
Thereafter, find the path through the my.application methods.
Build a correct path from that and launch it via process.start

jars, external properties, and external file io

I checked quite a few similar questions, but so far I am unsatisfied with the solutions.
Ever use the Minecraft Server? At initial launch, it creates all the files and folders it needs, and allows you to make changes to files like Server.properties and ops.txt by making them external of the executable jar file.
I'm working on a similar project, and I want to duplicate that behavior. Everything works great when I run it in eclipse. When I export to a jar file though, things get funky. The external files and folders are created without a hitch, but afterword, it would appear as though they cannot be read from or written to. Any ideas how Notch made his server?
--edit--
Scratch that, it doesn't even appear to reliably create the files and folders. Maybe it only creates them the very first run after creation?
--edit again--
It creates them in the root directory. When I tested it in eclipse, the root directory was limited to the folder containing the project, and therefore looked fine. The solution was to make the class aware of it's location, and include it in all file operations.
Have the main class in your executable jar file look up where it is, then have it store that information in a global String or something. Prefix your filenames with that string in your file operations, and voila! It's writing to the correct directory.

Which files are used by a program?

I have written a program on Visual Basic. In the debug folder, there are many files:
Database1.mdf
Database1_log.ldf
MyData.Designer.vb
MyData.xsc
MyData.xsd
MyData.xss
WindowsApplication1.exe
WindowsApplication1.config
WindowsApplication1.pdb
WindowsApplication1.vshost
WindowsApplication1.vshost.exe
WindowsApplication1.vshost.exe.manifest
WindowsApplication1.xml
I want to publish my program. Are all of those files necessary for the program? Which of them are used for my database?
Because I want to put a button in my program that backs up the database. Which files must be backed up?
First of all, you should publish the Release version of your software, not the debug version so the files will be a bit different. As for which files to publish, if you use the Setup project you will be able to select the files based upon what your application needs. For example, it looks like you are including database files with your application (Database1.mdf and Database1_log.ldf). You could add these files to the setup project.
The setup project will know to include your exe and your config file (unless you tell it not to) so you will be covered there. Here is a video and a written walkthrough of how to create a Setup project:
http://msdn.microsoft.com/en-us/library/ms241903.aspx
http://www.youtube.com/watch?v=Lcue0jo41AM
As for your PDB files, these are the Program Database Files that are used for debugging (and should never be give to the customer/end user).
http://msdn.microsoft.com/en-us/library/ms241903.aspx
As for backing up your database, back up the MDF and LDF files.
No, all of the files above are from your debug compile output. You can change what is output by changing your build configuration. Go to Build, Configuration Manager and switch to Release. It's also on the toolbar.
In general your ProjectName.exe (but not the .vshost.exe), .config (but not the .vshost.exe.config) and MDF/LDF files are needed for publishing. You also have an XSD File which will also be needed.
The MDF/LDF files are your database.