简体   繁体   中英

How to deploy files with a clickonce application?

I have some files, sound files (.wav and .mp3) and text files (.rtf), in my bin\\Debug folder during coding, but after publishing they are nowhere to be found.

My application can play sound files and these are the default sound files that are supposed to be installed with the application in the Application.Startup path.

The text *.rtf files I load into a RichtextBox control in my Help form for the application.

I have their properties set to Content and Copy if Newer.

You need to set these files as content (as you have) so that they get copied to the bin folder. Then open up the project properties page, select the "Publish" Tab and click "Application Files...". You should now see a list of files related to your project and value indicating how they should be published. More than likely your files have been marked as data and would be destined for your ClickOnce applications data folder not the bin folder. Either change your code to use the ClickOnce data folder (there are helper methods) or make sure that "Include" is selected and not "Data File".

Alternatively if the files are never expected to change on the client application you could consider embedding your files into your dll as a resource.

It's not clear to me -- have you added these files to your project in Visual Studio? If so, add them to the top level where your csproj file is, or put them in a folder under there (they will be deployed in the same relative path). I definitely would NOT be including files from the \\bin\\debug folder. You could easily wipe out your \\bin folder some time and there they go. I'm not sure you're doing that, but it sounds like you are.

If you put them in the top level of your project, they will be in the top level of your deployment. If you put them in a folder, they will be in that relative path. Set Build Action to "content", and I would set "copy to output directory" to "copy always".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM