Hi the problem I am faced with is after adding around 35 video files of both .avi and .mpg with a total file size of around half a gig to the resources of my project, I get an error message on debug telling me "Error 1 Unable to write to output file".
I am guessing this is because the total file size may be too large. I have tried to change the properties of the folder it writes to the file from read only, however it switches right back as soon as. Also I cannot see any .exe in the output directory where the file would be normally be written.
"C:\Users\Bill\Documents\Visual Studio 2010\Projects\resources test 2\resources test 2\obj\x86\Debug"
Resources test 2 being the project name.
I am trying to create a program which plays a number of short video clips without streaming them from the internet. If I could source them from a folder on the HDD then fine however I am then faced with the problem of adding the videos to the instaler package which I dont seem to be able to find a way to do. Does anyone know why the output file will not write in these circumstances? Thank you.

3 Years
Discussion Span
Last Post by tinstaafl

That's a new error message to me :/
Usually it's along the lines of cannot delete file blah blah...

Are you sure you do not have an instance of the program running? It may have crashed and did not fully unload from memory and release the file. Sometimes you will need to reboot to clear things up.

see: Unable to write to output file '<filename>': <error>


How are you doing the Deployment?

  • Publish to a Click-Once package?
  • A WIX installer?
  • Something else?

Thank you for your help guys, I am going to look into your pointer tinstaafi thanks for that.

Hi TnTinMN, yes it is a click once package, I am not sure what a WIX installer is but I can read up it. I guess there are third party installers but I would prefer not to use them.

I re wrote the project again and added one video file at a time. This time the .exe did get made in the bin directory. I added more videos and have now got to five. I am testing it to see how many it will take before gives it errors.

I think the error message was generated on the previous version because the file was already in use. Just a guess but I guess it like this. The video file is extracted from the .exe of the finished program or the temporary .exe made when I selected debug. The video gets copied to the hdd in a temporary folder but carries a temporary file extension. The video once on the hard drive then gets its extension changed to .avi then the media player gets told to play the file. I think the file is in use in this process somehow when the media player attempted to play it. It matters little because I am fairly certain the way I was trying to get this to work needed changing anyway. The idea by tinstaafi might well hold the answers.


Scrap emmbedding the video files.

Bring up the Solution Explorer: View Menu - > Solution Explorer
Add New Folder: Project Menu -> New Folder (Let's Name it Video)
In the "Solution Explorer" window, Selected the "Video" folder and then right-click->Add->Existing Item
Now Select your video files to include in the project.

For each video you add, set it's properties like this:

Build the Application.
Set the Publishing Options:

Now Publish it.

You can then load the video like this:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
   AxWindowsMediaPlayer1.currentMedia = AxWindowsMediaPlayer1.newMedia(ExecutionPath() & "\Video\Video1.avi")
End Sub

Public Function ExecutionPath() As String
   Return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
End Function

I've just built a sample version and it works perfect. Thank you all very much indeed.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.