That actually looks like exactly what I want... much cleaner than my C++
hackjob.

 

 

That gives me a followup question, however.  I plugged your suggestion
(with Depth="0") into my dialog I use to browse to the directory that
contains the file.

It appears that the property I'm trying to set to the browsed-to
directory doesn't contain the browsed-to directory when the
DirectorySearch is performed.

 

      <Dialog Id="GetExistingFilesDlg" Width="370" Height="270"
Title="[ProductName] [Setup]" NoMinimize="yes">

        <Control Id="PathEdit" Type="PathEdit" X="84" Y="202"
Width="261" Height="18" Property="MYFOLDER"/>

        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56"
Height="17" Default="yes" Text="Next">

              <Property Id="MYFILEEXISTS"> 

                        <DirectorySearch Id="MyDirSearch"
Path="[MYFOLDER]" Depth="0">

                                    <FileSearch Id="MyFileSearch"
Name="requiredfile.txt" />

                        </DirectorySearch> 

              </Property>

              <Publish Event="SpawnDialog" Value="InvalidDirDlg">NOT
MYFILEEXISTS</Publish>

              <Publish Event="NewDialog"
Value="SetupTypeDlg">MYFILEEXISTS</Publish>

        </Control>

 

 

I initialized MYFOLDER with <Property Id='MYFOLDER' Value='c:\' />

This works if requiredfile.txt is in c:\ (I can see
MYFILEEXISTS=c:\requiredfile.txt in the log)

It doesn't work if I browse to the directory that contains the file (and
of course I remove the file from c:\ )

 

Thanks for the help so far, this feels like a much better way than what
I was previously attempting.

________________________________

From: Levi Wilson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 15, 2007 3:50 PM
To: Rowland, Chris
Cc: wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] verify file existance custom action

 

Can you post your CA C++ code?  Also, you don't need to have a DLL
custom action to check for the existence of a file.  You can do
something like this in your WiX source:

<Property Id="MyFileExists"> 
  <DirectorySearch Id="MyDirSearch" Path="some path here" Depth="1">
    <FileSearch Id="MyFileSearch" Name="myfile.extension" />
  </DirectorySearch> 
</Property>


If the file has been found, then the MyFileExists property will be set
to the full path of your file.  Is this what you're looking for?

On 3/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

I read that "managed code" in a custom action is a no-no (please forgive
me if I use the wrong terminology) so I am attempting to write my custom
action without using managed code.  Most examples I find seem to use it,
however, so I'm doing the best I can.

 

I wrote a simple VC++ app (.exe) that will determine if some files
exist.  I probably did it badly, but it worked in that context. 

I took the same code, and cut& paste into a VC++ file I had setup to
create my dll.

The code was previously a working snippet that would simply set a msi
property to "true" and return ERROR_SUCCESS.

I am now trying to make it do something useful.

 

After the cut& paste I got some build errors and followed (somewhat) the
steps listed here to resolve them.
http://support.microsoft.com/?kbid=814472 

The dll built successfully, but when I run the installer I get error
2896, "Executing action [2] failed."  That doesn't tell me too much.

 

I stepped backwards until I had one line that I could comment/uncomment
to make the dll work(return "true")/not work(error 2896)

 

The one line that causes it to fail (and concequently causes the dll to
double in size) is:

 

ifstream fin1(filename);

 

Down the road I was doing 'if (fin1.good())' to see if the file exists
(like I said, probably a bad way, but it was the first thing I did that
seemed to work)

 

Is attempting to do this fundamentally wrong?

Also, I'm running the installer with /l* but I'm still not getting
anything particularly helpful.  Are there better techniques for
debugging?

 

 


------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your 
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users 

 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to