Click here to Skip to main content
15,748,615 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I display an image in an InkCanvas to be able to draw over. Then I record everything in a new image. If I specifies a new file name it works very well, the image file contains image + designs InkCanvas.
The problem is that I would save all under the name of the current image. But I have a crash due to problems of access rights.
In C# I have a "myPath" variable and the Xaml <Picture Source={binding myPath}/>.
How do I get out?

Thank you in advance.
Updated 11-Feb-14 6:35am
The14thNoah 11-Feb-14 22:14pm    
CAN YOU SHOW your code?
Pankaj Nikam 12-Feb-14 6:26am    
Please provide the code you have written in the save handler and load.
daphne35 13-Feb-14 4:32am    
Here are some parts of the code :

In the Xaml file :


<inkcanvas grid.row="1" x:name="myInkcanvas0">
<Image x:Name="img0" Source="{Binding Path0}" />

<inkcanvas grid.row="1" x:name="myInkcanvas1">
<Image x:Name="img1" Source="{Binding Path1}"/>

<Button Content="Save" Click="Save"/>

In the main cs file :

private void Save(object sender, RoutedEventArgs e)
SaveFile(((DisplayViewModel)this.DataContext).Path0, myInkcanvas0);
SaveFile(((DisplayViewModel)this.DataContext).Path0, myInkcanvas1);

private void SaveFile(string sPath, InkCanvas cnv)
FileStream stream = new FileStream(sPath, FileMode.Open, FileAccess.ReadWrite);
RenderTargetBitmap rtb = new RenderTargetBitmap(1200, 300, 0, 0, PixelFormats.Default);

BmpBitmapEncoder encoder = new BmpBitmapEncoder();


--> Exception : the process can not access to the file myfile.png because it is used by another process.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900