|
-
Jun 29th, 2009, 11:53 AM
#1
Thread Starter
Junior Member
vb .net 2005 deploy file only if doesnt exist
hi all, its me again 
here is the question (and i searched all over the web and found nothing):
Is it possible in the setup project to check if a file already exists on the user machine. if it does, then do nothing. if it doesnt, then put a default file.
ie. if a database exists, i dont want to overwrite it. i only want to put it in, if it DOES NOT already exists.
is there any setting in the setup project that i can set? maybe a condition (if so an example would be very very very helpful)?
thanks in advance.
-
Jun 30th, 2009, 01:33 AM
#2
Re: vb .net 2005 deploy file only if doesnt exist
The first thing to note is that VS Setup projects don't offer you the same power as a tool like InstallShield, so don't expect it.
As for the question, you'd probably need to add a Custom Action to your project and then you can do anything that VB can do because it's VB code.
-
Jun 30th, 2009, 08:34 AM
#3
Thread Starter
Junior Member
Re: vb .net 2005 deploy file only if doesnt exist
hey, thanks for your suggestions.
1st question, does installshield comes bundled with any version of VS?
2nd. as far as the setup projects, is there any way you can provide an example of how i would achieve this? what im not quite sure is what the path of my files would be in the compressed msi. i know i can use file.io to move/copy files around placing them in the proper directories. but im not sure how/where is their original directory, where i take them from.
do i have to actually take them out of the msi file, so that they are simply included in the the installer's folder? or is there another way to get it to work?
once again thank you for your help.
-
Jun 30th, 2009, 08:54 AM
#4
Re: vb .net 2005 deploy file only if doesnt exist
1. No, InstallShield is something you have to buy and it's not cheap. There are plenty of other tools to build Windows Installer packages though, if you want something with more power than a VS Setup project. Prices and functionality will vary.
2. A custom action is compiled VB code in a DLL or EXE so you can embed your files in that executable as a resource for easy access.
-
Jun 30th, 2009, 09:33 AM
#5
Thread Starter
Junior Member
Re: vb .net 2005 deploy file only if doesnt exist
ok, i think i will try to use the custom actions. however i am still very unclear on how to to that.
lets say i hae a setup project. it has an application folder (as usual) and a few other folders.

also i have an installer class where i so far put this code:
Code:
Private Sub BDSetup_AfterInstall(ByVal sender As Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles Me.AfterInstall
If Directory.Exists(Environment.CurrentDirectory & "\Database") = False Then
Directory.CreateDirectory(CheminGlobal & "\Database")
End If
If File.Exists(Environment.CurrentDirectoryl & "\Database\ParaLog.mdb") = False Then
Dim fSrc As String = ????? 'What would i put here to get my database?????
End If
End Sub
what do i have to put in the Dim fSrc As String =. I have no idea where the database will be included in and how to extract it from the msi package.
as usual, your help is greatly appreciated.
-
Jun 30th, 2009, 07:15 PM
#6
Re: vb .net 2005 deploy file only if doesnt exist
As I said, you would embed the file as a resource and then access it like you would any other resource, i.e. via My.Resources. Note that you are NOT copying a file by path. When you extract the file from your resources it will be in binary form, i.e. a Byte array. You will need to write that data to the destination file path, which you'd most likely do by calling File.WriteAllBytes. You could also use a FileStream but that's more work so why bother?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|