Error Displaying Tiff Image to DocumentViewer (WPF,C#)WPF image resourcesSetting WPF image source in codeDoes my code demonstrate good WPF practice?I need to view a Multipage TIFF in a WPF applicationwpf DocumentViewer - get ITextPointer by GlyphRun and vice versaWPF DocumentViewer - Print with no confirmationSetting the cursor in a WPF documentViewerWPF to powershell errorsNavigate to other page IocContainers and MVVM lightC# wpf documentviewer getPageSize?

Is a stroke of luck acceptable after a series of unfavorable events?

India just shot down a satellite from the ground. At what altitude range is the resulting debris field?

Failed to fetch jessie backports repository

Detecting if an element is found inside a container

A particular customize with green line and letters for subfloat

How does Loki do this?

Term for the "extreme-extension" version of a straw man fallacy?

What is the difference between "behavior" and "behaviour"?

Is `x >> pure y` equivalent to `liftM (const y) x`

Do sorcerers' Subtle Spells require a skill check to be unseen?

How does it work when somebody invests in my business?

Lay out the Carpet

Integer addition + constant, is it a group?

Class Action - which options I have?

Large drywall patch supports

Is expanding the research of a group into machine learning as a PhD student risky?

Why escape if the_content isnt?

Hostile work environment after whistle-blowing on coworker and our boss. What do I do?

Go Pregnant or Go Home

Inappropriate reference requests from Journal reviewers

How to write papers efficiently when English isn't my first language?

Two monoidal structures and copowering

Is there a good way to store credentials outside of a password manager?

Method to test if a number is a perfect power?



Error Displaying Tiff Image to DocumentViewer (WPF,C#)


WPF image resourcesSetting WPF image source in codeDoes my code demonstrate good WPF practice?I need to view a Multipage TIFF in a WPF applicationwpf DocumentViewer - get ITextPointer by GlyphRun and vice versaWPF DocumentViewer - Print with no confirmationSetting the cursor in a WPF documentViewerWPF to powershell errorsNavigate to other page IocContainers and MVVM lightC# wpf documentviewer getPageSize?













3















Hello Everyone I want to use DocumentViewer control to display Multipage Tiffs.The code i have written is the following...



using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Tiff_Viewer

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window

private System.Windows.Controls.Image _Image;
private System.Windows.Documents.FixedDocument _FixedDocument;
private System.Windows.Documents.FixedPage _FixedPage;
private System.Windows.Documents.PageContent _PageContent;
public MainWindow()

InitializeComponent();



private void testbutton_Click(object sender, RoutedEventArgs e)

try

this._Image = new Image();
FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);
TiffBitmapDecoder ImageDecoder = new TiffBitmapDecoder(ImageStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

//BitmapSource bitmapSource = ImageDecoder.Frames[0];
this._Image.Source = ImageDecoder.Frames[0];
//this._Image.Source = new BitmapImage(new Uri("C:\Users\ttsa\Desktop\DocumentViewerTest\AAA0011A.tif", UriKind.Relative));
this._Image.Stretch = Stretch.None;
this._Image.Margin = new Thickness(20);

this._FixedPage = new System.Windows.Documents.FixedPage();
this._FixedPage.Width = 1000;
this._FixedPage.Height = 1000;
this._FixedPage.Children.Add(this._Image);

this._PageContent = new System.Windows.Documents.PageContent();
this._PageContent.Child = this._FixedPage;

this._FixedDocument = new FixedDocument();
this._FixedDocument.Pages.Add(this._PageContent);

DocumentViewer.Document = this._FixedDocument;
//DocumentViewer.LastPage();

catch (Exception fd)

System.Windows.MessageBox.Show(fd.Message);






-------------------------------WPF---------------------------------------------------------------------------



<Window x:Class="Tiff_Viewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Tiff_Viewer"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<DocumentViewer Grid.Row="1" x:Name="DocumentViewer" HorizontalAlignment="Left" Margin="0,41,0,0" VerticalAlignment="Top"/>
<Button HorizontalAlignment="left" Content="TEST" Name="testbutton" Grid.Row="0" Width="30" Click="testbutton_Click"/>
</Grid>




I have tried to take and display only one frame-page from the TIFF.However when i run the program it does show the page i want BUT when i move the cursor of the mouse inside the Document Viewer and specifically inside the image i keep getting the following error:




"System.IO.FileNotFoundException: 'Could not find file
'C:UsersttsaDesktopTIFF_ViewerTiff_ViewerTiff_ViewerbinDebugimage'.'".




enter image description here



I have tried almost everything and i cant find a way to fix this.
Does anyone knows anything about this? Is there something i can do to fix it?
Or else does anyone knows another way to display multipage tiff to DocumentViewer???



Thanks in advance!!!










share|improve this question
























  • The error message is in plain simple English. Start with actually reading the error message. It very much tells you what your problem is (and also points at how you can fix it...)

    – elgonzo
    Mar 8 at 11:33












  • Thanks for your response!!! I have tried everything means ofc i have read the message and ofc i have searched the whole google as well as putting breakpoints to see where the code breaks but i havent find a solution.So if you have one share it with us i would really appreciate it :)

    – Fanis Tsatsaronis
    Mar 8 at 11:50











  • My advice is that you make sure your code is using the correct path when trying to load/access the TIFF image. Your code example in the question uses the placeholder "THE PATH TO MULTIPAGE TIF" for the actual file path. Just follow your own suggestion there: use the (correct!) path to the multipage tif...

    – elgonzo
    Mar 8 at 11:53












  • I am 100% sure that i put the correct path so this is not the problem but thanks for your advice and for your help.If you have anything else to suggest i will be glad to hear.I have uploaded all the code both .xaml and .cs if you want to try it :)

    – Fanis Tsatsaronis
    Mar 8 at 12:06











  • Well, if you are really 100% sure that you put the correct path there, then look at the stacktrace of the exception. It will tell you which method threw the exception, and it will also tell you which methods of your own code were involved in calling the method that threw the exception. With that information you should be able to debug your code in a meaningful manner to see what is really going on...

    – elgonzo
    Mar 8 at 12:10
















3















Hello Everyone I want to use DocumentViewer control to display Multipage Tiffs.The code i have written is the following...



using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Tiff_Viewer

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window

private System.Windows.Controls.Image _Image;
private System.Windows.Documents.FixedDocument _FixedDocument;
private System.Windows.Documents.FixedPage _FixedPage;
private System.Windows.Documents.PageContent _PageContent;
public MainWindow()

InitializeComponent();



private void testbutton_Click(object sender, RoutedEventArgs e)

try

this._Image = new Image();
FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);
TiffBitmapDecoder ImageDecoder = new TiffBitmapDecoder(ImageStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

//BitmapSource bitmapSource = ImageDecoder.Frames[0];
this._Image.Source = ImageDecoder.Frames[0];
//this._Image.Source = new BitmapImage(new Uri("C:\Users\ttsa\Desktop\DocumentViewerTest\AAA0011A.tif", UriKind.Relative));
this._Image.Stretch = Stretch.None;
this._Image.Margin = new Thickness(20);

this._FixedPage = new System.Windows.Documents.FixedPage();
this._FixedPage.Width = 1000;
this._FixedPage.Height = 1000;
this._FixedPage.Children.Add(this._Image);

this._PageContent = new System.Windows.Documents.PageContent();
this._PageContent.Child = this._FixedPage;

this._FixedDocument = new FixedDocument();
this._FixedDocument.Pages.Add(this._PageContent);

DocumentViewer.Document = this._FixedDocument;
//DocumentViewer.LastPage();

catch (Exception fd)

System.Windows.MessageBox.Show(fd.Message);






-------------------------------WPF---------------------------------------------------------------------------



<Window x:Class="Tiff_Viewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Tiff_Viewer"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<DocumentViewer Grid.Row="1" x:Name="DocumentViewer" HorizontalAlignment="Left" Margin="0,41,0,0" VerticalAlignment="Top"/>
<Button HorizontalAlignment="left" Content="TEST" Name="testbutton" Grid.Row="0" Width="30" Click="testbutton_Click"/>
</Grid>




I have tried to take and display only one frame-page from the TIFF.However when i run the program it does show the page i want BUT when i move the cursor of the mouse inside the Document Viewer and specifically inside the image i keep getting the following error:




"System.IO.FileNotFoundException: 'Could not find file
'C:UsersttsaDesktopTIFF_ViewerTiff_ViewerTiff_ViewerbinDebugimage'.'".




enter image description here



I have tried almost everything and i cant find a way to fix this.
Does anyone knows anything about this? Is there something i can do to fix it?
Or else does anyone knows another way to display multipage tiff to DocumentViewer???



Thanks in advance!!!










share|improve this question
























  • The error message is in plain simple English. Start with actually reading the error message. It very much tells you what your problem is (and also points at how you can fix it...)

    – elgonzo
    Mar 8 at 11:33












  • Thanks for your response!!! I have tried everything means ofc i have read the message and ofc i have searched the whole google as well as putting breakpoints to see where the code breaks but i havent find a solution.So if you have one share it with us i would really appreciate it :)

    – Fanis Tsatsaronis
    Mar 8 at 11:50











  • My advice is that you make sure your code is using the correct path when trying to load/access the TIFF image. Your code example in the question uses the placeholder "THE PATH TO MULTIPAGE TIF" for the actual file path. Just follow your own suggestion there: use the (correct!) path to the multipage tif...

    – elgonzo
    Mar 8 at 11:53












  • I am 100% sure that i put the correct path so this is not the problem but thanks for your advice and for your help.If you have anything else to suggest i will be glad to hear.I have uploaded all the code both .xaml and .cs if you want to try it :)

    – Fanis Tsatsaronis
    Mar 8 at 12:06











  • Well, if you are really 100% sure that you put the correct path there, then look at the stacktrace of the exception. It will tell you which method threw the exception, and it will also tell you which methods of your own code were involved in calling the method that threw the exception. With that information you should be able to debug your code in a meaningful manner to see what is really going on...

    – elgonzo
    Mar 8 at 12:10














3












3








3








Hello Everyone I want to use DocumentViewer control to display Multipage Tiffs.The code i have written is the following...



using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Tiff_Viewer

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window

private System.Windows.Controls.Image _Image;
private System.Windows.Documents.FixedDocument _FixedDocument;
private System.Windows.Documents.FixedPage _FixedPage;
private System.Windows.Documents.PageContent _PageContent;
public MainWindow()

InitializeComponent();



private void testbutton_Click(object sender, RoutedEventArgs e)

try

this._Image = new Image();
FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);
TiffBitmapDecoder ImageDecoder = new TiffBitmapDecoder(ImageStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

//BitmapSource bitmapSource = ImageDecoder.Frames[0];
this._Image.Source = ImageDecoder.Frames[0];
//this._Image.Source = new BitmapImage(new Uri("C:\Users\ttsa\Desktop\DocumentViewerTest\AAA0011A.tif", UriKind.Relative));
this._Image.Stretch = Stretch.None;
this._Image.Margin = new Thickness(20);

this._FixedPage = new System.Windows.Documents.FixedPage();
this._FixedPage.Width = 1000;
this._FixedPage.Height = 1000;
this._FixedPage.Children.Add(this._Image);

this._PageContent = new System.Windows.Documents.PageContent();
this._PageContent.Child = this._FixedPage;

this._FixedDocument = new FixedDocument();
this._FixedDocument.Pages.Add(this._PageContent);

DocumentViewer.Document = this._FixedDocument;
//DocumentViewer.LastPage();

catch (Exception fd)

System.Windows.MessageBox.Show(fd.Message);






-------------------------------WPF---------------------------------------------------------------------------



<Window x:Class="Tiff_Viewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Tiff_Viewer"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<DocumentViewer Grid.Row="1" x:Name="DocumentViewer" HorizontalAlignment="Left" Margin="0,41,0,0" VerticalAlignment="Top"/>
<Button HorizontalAlignment="left" Content="TEST" Name="testbutton" Grid.Row="0" Width="30" Click="testbutton_Click"/>
</Grid>




I have tried to take and display only one frame-page from the TIFF.However when i run the program it does show the page i want BUT when i move the cursor of the mouse inside the Document Viewer and specifically inside the image i keep getting the following error:




"System.IO.FileNotFoundException: 'Could not find file
'C:UsersttsaDesktopTIFF_ViewerTiff_ViewerTiff_ViewerbinDebugimage'.'".




enter image description here



I have tried almost everything and i cant find a way to fix this.
Does anyone knows anything about this? Is there something i can do to fix it?
Or else does anyone knows another way to display multipage tiff to DocumentViewer???



Thanks in advance!!!










share|improve this question
















Hello Everyone I want to use DocumentViewer control to display Multipage Tiffs.The code i have written is the following...



using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Tiff_Viewer

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window

private System.Windows.Controls.Image _Image;
private System.Windows.Documents.FixedDocument _FixedDocument;
private System.Windows.Documents.FixedPage _FixedPage;
private System.Windows.Documents.PageContent _PageContent;
public MainWindow()

InitializeComponent();



private void testbutton_Click(object sender, RoutedEventArgs e)

try

this._Image = new Image();
FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);
TiffBitmapDecoder ImageDecoder = new TiffBitmapDecoder(ImageStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

//BitmapSource bitmapSource = ImageDecoder.Frames[0];
this._Image.Source = ImageDecoder.Frames[0];
//this._Image.Source = new BitmapImage(new Uri("C:\Users\ttsa\Desktop\DocumentViewerTest\AAA0011A.tif", UriKind.Relative));
this._Image.Stretch = Stretch.None;
this._Image.Margin = new Thickness(20);

this._FixedPage = new System.Windows.Documents.FixedPage();
this._FixedPage.Width = 1000;
this._FixedPage.Height = 1000;
this._FixedPage.Children.Add(this._Image);

this._PageContent = new System.Windows.Documents.PageContent();
this._PageContent.Child = this._FixedPage;

this._FixedDocument = new FixedDocument();
this._FixedDocument.Pages.Add(this._PageContent);

DocumentViewer.Document = this._FixedDocument;
//DocumentViewer.LastPage();

catch (Exception fd)

System.Windows.MessageBox.Show(fd.Message);






-------------------------------WPF---------------------------------------------------------------------------



<Window x:Class="Tiff_Viewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Tiff_Viewer"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<DocumentViewer Grid.Row="1" x:Name="DocumentViewer" HorizontalAlignment="Left" Margin="0,41,0,0" VerticalAlignment="Top"/>
<Button HorizontalAlignment="left" Content="TEST" Name="testbutton" Grid.Row="0" Width="30" Click="testbutton_Click"/>
</Grid>




I have tried to take and display only one frame-page from the TIFF.However when i run the program it does show the page i want BUT when i move the cursor of the mouse inside the Document Viewer and specifically inside the image i keep getting the following error:




"System.IO.FileNotFoundException: 'Could not find file
'C:UsersttsaDesktopTIFF_ViewerTiff_ViewerTiff_ViewerbinDebugimage'.'".




enter image description here



I have tried almost everything and i cant find a way to fix this.
Does anyone knows anything about this? Is there something i can do to fix it?
Or else does anyone knows another way to display multipage tiff to DocumentViewer???



Thanks in advance!!!







c# wpf tiff multipage documentviewer






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 12:03







Fanis Tsatsaronis

















asked Mar 8 at 11:18









Fanis TsatsaronisFanis Tsatsaronis

466




466












  • The error message is in plain simple English. Start with actually reading the error message. It very much tells you what your problem is (and also points at how you can fix it...)

    – elgonzo
    Mar 8 at 11:33












  • Thanks for your response!!! I have tried everything means ofc i have read the message and ofc i have searched the whole google as well as putting breakpoints to see where the code breaks but i havent find a solution.So if you have one share it with us i would really appreciate it :)

    – Fanis Tsatsaronis
    Mar 8 at 11:50











  • My advice is that you make sure your code is using the correct path when trying to load/access the TIFF image. Your code example in the question uses the placeholder "THE PATH TO MULTIPAGE TIF" for the actual file path. Just follow your own suggestion there: use the (correct!) path to the multipage tif...

    – elgonzo
    Mar 8 at 11:53












  • I am 100% sure that i put the correct path so this is not the problem but thanks for your advice and for your help.If you have anything else to suggest i will be glad to hear.I have uploaded all the code both .xaml and .cs if you want to try it :)

    – Fanis Tsatsaronis
    Mar 8 at 12:06











  • Well, if you are really 100% sure that you put the correct path there, then look at the stacktrace of the exception. It will tell you which method threw the exception, and it will also tell you which methods of your own code were involved in calling the method that threw the exception. With that information you should be able to debug your code in a meaningful manner to see what is really going on...

    – elgonzo
    Mar 8 at 12:10


















  • The error message is in plain simple English. Start with actually reading the error message. It very much tells you what your problem is (and also points at how you can fix it...)

    – elgonzo
    Mar 8 at 11:33












  • Thanks for your response!!! I have tried everything means ofc i have read the message and ofc i have searched the whole google as well as putting breakpoints to see where the code breaks but i havent find a solution.So if you have one share it with us i would really appreciate it :)

    – Fanis Tsatsaronis
    Mar 8 at 11:50











  • My advice is that you make sure your code is using the correct path when trying to load/access the TIFF image. Your code example in the question uses the placeholder "THE PATH TO MULTIPAGE TIF" for the actual file path. Just follow your own suggestion there: use the (correct!) path to the multipage tif...

    – elgonzo
    Mar 8 at 11:53












  • I am 100% sure that i put the correct path so this is not the problem but thanks for your advice and for your help.If you have anything else to suggest i will be glad to hear.I have uploaded all the code both .xaml and .cs if you want to try it :)

    – Fanis Tsatsaronis
    Mar 8 at 12:06











  • Well, if you are really 100% sure that you put the correct path there, then look at the stacktrace of the exception. It will tell you which method threw the exception, and it will also tell you which methods of your own code were involved in calling the method that threw the exception. With that information you should be able to debug your code in a meaningful manner to see what is really going on...

    – elgonzo
    Mar 8 at 12:10

















The error message is in plain simple English. Start with actually reading the error message. It very much tells you what your problem is (and also points at how you can fix it...)

– elgonzo
Mar 8 at 11:33






The error message is in plain simple English. Start with actually reading the error message. It very much tells you what your problem is (and also points at how you can fix it...)

– elgonzo
Mar 8 at 11:33














Thanks for your response!!! I have tried everything means ofc i have read the message and ofc i have searched the whole google as well as putting breakpoints to see where the code breaks but i havent find a solution.So if you have one share it with us i would really appreciate it :)

– Fanis Tsatsaronis
Mar 8 at 11:50





Thanks for your response!!! I have tried everything means ofc i have read the message and ofc i have searched the whole google as well as putting breakpoints to see where the code breaks but i havent find a solution.So if you have one share it with us i would really appreciate it :)

– Fanis Tsatsaronis
Mar 8 at 11:50













My advice is that you make sure your code is using the correct path when trying to load/access the TIFF image. Your code example in the question uses the placeholder "THE PATH TO MULTIPAGE TIF" for the actual file path. Just follow your own suggestion there: use the (correct!) path to the multipage tif...

– elgonzo
Mar 8 at 11:53






My advice is that you make sure your code is using the correct path when trying to load/access the TIFF image. Your code example in the question uses the placeholder "THE PATH TO MULTIPAGE TIF" for the actual file path. Just follow your own suggestion there: use the (correct!) path to the multipage tif...

– elgonzo
Mar 8 at 11:53














I am 100% sure that i put the correct path so this is not the problem but thanks for your advice and for your help.If you have anything else to suggest i will be glad to hear.I have uploaded all the code both .xaml and .cs if you want to try it :)

– Fanis Tsatsaronis
Mar 8 at 12:06





I am 100% sure that i put the correct path so this is not the problem but thanks for your advice and for your help.If you have anything else to suggest i will be glad to hear.I have uploaded all the code both .xaml and .cs if you want to try it :)

– Fanis Tsatsaronis
Mar 8 at 12:06













Well, if you are really 100% sure that you put the correct path there, then look at the stacktrace of the exception. It will tell you which method threw the exception, and it will also tell you which methods of your own code were involved in calling the method that threw the exception. With that information you should be able to debug your code in a meaningful manner to see what is really going on...

– elgonzo
Mar 8 at 12:10






Well, if you are really 100% sure that you put the correct path there, then look at the stacktrace of the exception. It will tell you which method threw the exception, and it will also tell you which methods of your own code were involved in calling the method that threw the exception. With that information you should be able to debug your code in a meaningful manner to see what is really going on...

– elgonzo
Mar 8 at 12:10













2 Answers
2






active

oldest

votes


















1














I did make a copy of your code and you are not the only one with the exception.
I don't know why the documentviewer trows the 'File not found exception', if someone can explain this it would be appreciated.



One way I have found to solve this is to put the image stream inside a BitmapImage before loading it in the document viewer. The only problem is that I can't get this to work with a multipage Tiff:



BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ImageStream;
bi.EndInit();
this._Image.Source = bi;


One way to make it work with a multipage tiff is kind of a hack, you could just create the file the program is asking for. It needs to be a file named Image witout a file extension, also it needs to be a Tiff file structure. It can be any tiff but for this I did make a copy of the tiff we show in the documentviewer. When there is already a Image file, there is no need to copy it again.



string pathToTiff = @"C: UsersdeveloperDesktoptemptest.tif";

this._Image = new Image();
FileStream ImageStream = new FileStream(pathToTiff, FileMode.Open, FileAccess.Read,
FileShare.Read);
TiffBitmapDecoder ImageDecoder = new TiffBitmapDecoder(ImageStream,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

this._FixedDocument = new FixedDocument();

if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"Image"))

File.Copy(pathToTiff, AppDomain.CurrentDomain.BaseDirectory + @"Image", true);


foreach (BitmapFrame f in ImageDecoder.Frames)

this._Image = new Image();
this._Image.Source = f.Clone(); ;
this._Image.Stretch = Stretch.None;
this._Image.Margin = new Thickness(20);

this._FixedPage = new System.Windows.Documents.FixedPage();
this._FixedPage.Width = 1000;
this._FixedPage.Height = 1000;
this._FixedPage.Children.Add(this._Image);

this._PageContent = new System.Windows.Documents.PageContent();
this._PageContent.Child = this._FixedPage;
this._FixedDocument.Pages.Add(this._PageContent);

documentViewer.Document = this._FixedDocument;





share|improve this answer























  • I have no words to thank you at the moment.It actually worked and if you believe it i tried it too before i post the error here but i just created a txt file that i renamed it to image without the extension and it didnt work.With your suggestion for tiff it worked like a charm.You are a life savior bro i really appreciate it.Thank you sooo much :)

    – Fanis Tsatsaronis
    Mar 8 at 15:34


















0














Im assuming, that the path shown in your exception message, is your actual FileStream path. You might need to add the extension of the file aswell (for example: "..Debugimage.tif").






share|improve this answer























  • Thanks for your response.Unfortunately it isn't the actual FileStream path. FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);

    – Fanis Tsatsaronis
    Mar 8 at 11:46












  • Is there any other function in your app, that is trying to reach the file shown in your error?

    – Pookie
    Mar 8 at 11:54











  • No i just use a button and the DocumentViewer and the case is when i push the button i want the tiff to be displayed in the DocumentViewer.I have uploaded all the code both .xaml and .cs if you want to try it for yourself.I am glad to hear if you have anything else to propose :)

    – Fanis Tsatsaronis
    Mar 8 at 12:08










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55062144%2ferror-displaying-tiff-image-to-documentviewer-wpf-c%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I did make a copy of your code and you are not the only one with the exception.
I don't know why the documentviewer trows the 'File not found exception', if someone can explain this it would be appreciated.



One way I have found to solve this is to put the image stream inside a BitmapImage before loading it in the document viewer. The only problem is that I can't get this to work with a multipage Tiff:



BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ImageStream;
bi.EndInit();
this._Image.Source = bi;


One way to make it work with a multipage tiff is kind of a hack, you could just create the file the program is asking for. It needs to be a file named Image witout a file extension, also it needs to be a Tiff file structure. It can be any tiff but for this I did make a copy of the tiff we show in the documentviewer. When there is already a Image file, there is no need to copy it again.



string pathToTiff = @"C: UsersdeveloperDesktoptemptest.tif";

this._Image = new Image();
FileStream ImageStream = new FileStream(pathToTiff, FileMode.Open, FileAccess.Read,
FileShare.Read);
TiffBitmapDecoder ImageDecoder = new TiffBitmapDecoder(ImageStream,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

this._FixedDocument = new FixedDocument();

if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"Image"))

File.Copy(pathToTiff, AppDomain.CurrentDomain.BaseDirectory + @"Image", true);


foreach (BitmapFrame f in ImageDecoder.Frames)

this._Image = new Image();
this._Image.Source = f.Clone(); ;
this._Image.Stretch = Stretch.None;
this._Image.Margin = new Thickness(20);

this._FixedPage = new System.Windows.Documents.FixedPage();
this._FixedPage.Width = 1000;
this._FixedPage.Height = 1000;
this._FixedPage.Children.Add(this._Image);

this._PageContent = new System.Windows.Documents.PageContent();
this._PageContent.Child = this._FixedPage;
this._FixedDocument.Pages.Add(this._PageContent);

documentViewer.Document = this._FixedDocument;





share|improve this answer























  • I have no words to thank you at the moment.It actually worked and if you believe it i tried it too before i post the error here but i just created a txt file that i renamed it to image without the extension and it didnt work.With your suggestion for tiff it worked like a charm.You are a life savior bro i really appreciate it.Thank you sooo much :)

    – Fanis Tsatsaronis
    Mar 8 at 15:34















1














I did make a copy of your code and you are not the only one with the exception.
I don't know why the documentviewer trows the 'File not found exception', if someone can explain this it would be appreciated.



One way I have found to solve this is to put the image stream inside a BitmapImage before loading it in the document viewer. The only problem is that I can't get this to work with a multipage Tiff:



BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ImageStream;
bi.EndInit();
this._Image.Source = bi;


One way to make it work with a multipage tiff is kind of a hack, you could just create the file the program is asking for. It needs to be a file named Image witout a file extension, also it needs to be a Tiff file structure. It can be any tiff but for this I did make a copy of the tiff we show in the documentviewer. When there is already a Image file, there is no need to copy it again.



string pathToTiff = @"C: UsersdeveloperDesktoptemptest.tif";

this._Image = new Image();
FileStream ImageStream = new FileStream(pathToTiff, FileMode.Open, FileAccess.Read,
FileShare.Read);
TiffBitmapDecoder ImageDecoder = new TiffBitmapDecoder(ImageStream,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

this._FixedDocument = new FixedDocument();

if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"Image"))

File.Copy(pathToTiff, AppDomain.CurrentDomain.BaseDirectory + @"Image", true);


foreach (BitmapFrame f in ImageDecoder.Frames)

this._Image = new Image();
this._Image.Source = f.Clone(); ;
this._Image.Stretch = Stretch.None;
this._Image.Margin = new Thickness(20);

this._FixedPage = new System.Windows.Documents.FixedPage();
this._FixedPage.Width = 1000;
this._FixedPage.Height = 1000;
this._FixedPage.Children.Add(this._Image);

this._PageContent = new System.Windows.Documents.PageContent();
this._PageContent.Child = this._FixedPage;
this._FixedDocument.Pages.Add(this._PageContent);

documentViewer.Document = this._FixedDocument;





share|improve this answer























  • I have no words to thank you at the moment.It actually worked and if you believe it i tried it too before i post the error here but i just created a txt file that i renamed it to image without the extension and it didnt work.With your suggestion for tiff it worked like a charm.You are a life savior bro i really appreciate it.Thank you sooo much :)

    – Fanis Tsatsaronis
    Mar 8 at 15:34













1












1








1







I did make a copy of your code and you are not the only one with the exception.
I don't know why the documentviewer trows the 'File not found exception', if someone can explain this it would be appreciated.



One way I have found to solve this is to put the image stream inside a BitmapImage before loading it in the document viewer. The only problem is that I can't get this to work with a multipage Tiff:



BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ImageStream;
bi.EndInit();
this._Image.Source = bi;


One way to make it work with a multipage tiff is kind of a hack, you could just create the file the program is asking for. It needs to be a file named Image witout a file extension, also it needs to be a Tiff file structure. It can be any tiff but for this I did make a copy of the tiff we show in the documentviewer. When there is already a Image file, there is no need to copy it again.



string pathToTiff = @"C: UsersdeveloperDesktoptemptest.tif";

this._Image = new Image();
FileStream ImageStream = new FileStream(pathToTiff, FileMode.Open, FileAccess.Read,
FileShare.Read);
TiffBitmapDecoder ImageDecoder = new TiffBitmapDecoder(ImageStream,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

this._FixedDocument = new FixedDocument();

if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"Image"))

File.Copy(pathToTiff, AppDomain.CurrentDomain.BaseDirectory + @"Image", true);


foreach (BitmapFrame f in ImageDecoder.Frames)

this._Image = new Image();
this._Image.Source = f.Clone(); ;
this._Image.Stretch = Stretch.None;
this._Image.Margin = new Thickness(20);

this._FixedPage = new System.Windows.Documents.FixedPage();
this._FixedPage.Width = 1000;
this._FixedPage.Height = 1000;
this._FixedPage.Children.Add(this._Image);

this._PageContent = new System.Windows.Documents.PageContent();
this._PageContent.Child = this._FixedPage;
this._FixedDocument.Pages.Add(this._PageContent);

documentViewer.Document = this._FixedDocument;





share|improve this answer













I did make a copy of your code and you are not the only one with the exception.
I don't know why the documentviewer trows the 'File not found exception', if someone can explain this it would be appreciated.



One way I have found to solve this is to put the image stream inside a BitmapImage before loading it in the document viewer. The only problem is that I can't get this to work with a multipage Tiff:



BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ImageStream;
bi.EndInit();
this._Image.Source = bi;


One way to make it work with a multipage tiff is kind of a hack, you could just create the file the program is asking for. It needs to be a file named Image witout a file extension, also it needs to be a Tiff file structure. It can be any tiff but for this I did make a copy of the tiff we show in the documentviewer. When there is already a Image file, there is no need to copy it again.



string pathToTiff = @"C: UsersdeveloperDesktoptemptest.tif";

this._Image = new Image();
FileStream ImageStream = new FileStream(pathToTiff, FileMode.Open, FileAccess.Read,
FileShare.Read);
TiffBitmapDecoder ImageDecoder = new TiffBitmapDecoder(ImageStream,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

this._FixedDocument = new FixedDocument();

if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"Image"))

File.Copy(pathToTiff, AppDomain.CurrentDomain.BaseDirectory + @"Image", true);


foreach (BitmapFrame f in ImageDecoder.Frames)

this._Image = new Image();
this._Image.Source = f.Clone(); ;
this._Image.Stretch = Stretch.None;
this._Image.Margin = new Thickness(20);

this._FixedPage = new System.Windows.Documents.FixedPage();
this._FixedPage.Width = 1000;
this._FixedPage.Height = 1000;
this._FixedPage.Children.Add(this._Image);

this._PageContent = new System.Windows.Documents.PageContent();
this._PageContent.Child = this._FixedPage;
this._FixedDocument.Pages.Add(this._PageContent);

documentViewer.Document = this._FixedDocument;






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 8 at 14:31









DjangoSoeDjangoSoe

463




463












  • I have no words to thank you at the moment.It actually worked and if you believe it i tried it too before i post the error here but i just created a txt file that i renamed it to image without the extension and it didnt work.With your suggestion for tiff it worked like a charm.You are a life savior bro i really appreciate it.Thank you sooo much :)

    – Fanis Tsatsaronis
    Mar 8 at 15:34

















  • I have no words to thank you at the moment.It actually worked and if you believe it i tried it too before i post the error here but i just created a txt file that i renamed it to image without the extension and it didnt work.With your suggestion for tiff it worked like a charm.You are a life savior bro i really appreciate it.Thank you sooo much :)

    – Fanis Tsatsaronis
    Mar 8 at 15:34
















I have no words to thank you at the moment.It actually worked and if you believe it i tried it too before i post the error here but i just created a txt file that i renamed it to image without the extension and it didnt work.With your suggestion for tiff it worked like a charm.You are a life savior bro i really appreciate it.Thank you sooo much :)

– Fanis Tsatsaronis
Mar 8 at 15:34





I have no words to thank you at the moment.It actually worked and if you believe it i tried it too before i post the error here but i just created a txt file that i renamed it to image without the extension and it didnt work.With your suggestion for tiff it worked like a charm.You are a life savior bro i really appreciate it.Thank you sooo much :)

– Fanis Tsatsaronis
Mar 8 at 15:34













0














Im assuming, that the path shown in your exception message, is your actual FileStream path. You might need to add the extension of the file aswell (for example: "..Debugimage.tif").






share|improve this answer























  • Thanks for your response.Unfortunately it isn't the actual FileStream path. FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);

    – Fanis Tsatsaronis
    Mar 8 at 11:46












  • Is there any other function in your app, that is trying to reach the file shown in your error?

    – Pookie
    Mar 8 at 11:54











  • No i just use a button and the DocumentViewer and the case is when i push the button i want the tiff to be displayed in the DocumentViewer.I have uploaded all the code both .xaml and .cs if you want to try it for yourself.I am glad to hear if you have anything else to propose :)

    – Fanis Tsatsaronis
    Mar 8 at 12:08















0














Im assuming, that the path shown in your exception message, is your actual FileStream path. You might need to add the extension of the file aswell (for example: "..Debugimage.tif").






share|improve this answer























  • Thanks for your response.Unfortunately it isn't the actual FileStream path. FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);

    – Fanis Tsatsaronis
    Mar 8 at 11:46












  • Is there any other function in your app, that is trying to reach the file shown in your error?

    – Pookie
    Mar 8 at 11:54











  • No i just use a button and the DocumentViewer and the case is when i push the button i want the tiff to be displayed in the DocumentViewer.I have uploaded all the code both .xaml and .cs if you want to try it for yourself.I am glad to hear if you have anything else to propose :)

    – Fanis Tsatsaronis
    Mar 8 at 12:08













0












0








0







Im assuming, that the path shown in your exception message, is your actual FileStream path. You might need to add the extension of the file aswell (for example: "..Debugimage.tif").






share|improve this answer













Im assuming, that the path shown in your exception message, is your actual FileStream path. You might need to add the extension of the file aswell (for example: "..Debugimage.tif").







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 8 at 11:44









PookiePookie

11




11












  • Thanks for your response.Unfortunately it isn't the actual FileStream path. FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);

    – Fanis Tsatsaronis
    Mar 8 at 11:46












  • Is there any other function in your app, that is trying to reach the file shown in your error?

    – Pookie
    Mar 8 at 11:54











  • No i just use a button and the DocumentViewer and the case is when i push the button i want the tiff to be displayed in the DocumentViewer.I have uploaded all the code both .xaml and .cs if you want to try it for yourself.I am glad to hear if you have anything else to propose :)

    – Fanis Tsatsaronis
    Mar 8 at 12:08

















  • Thanks for your response.Unfortunately it isn't the actual FileStream path. FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);

    – Fanis Tsatsaronis
    Mar 8 at 11:46












  • Is there any other function in your app, that is trying to reach the file shown in your error?

    – Pookie
    Mar 8 at 11:54











  • No i just use a button and the DocumentViewer and the case is when i push the button i want the tiff to be displayed in the DocumentViewer.I have uploaded all the code both .xaml and .cs if you want to try it for yourself.I am glad to hear if you have anything else to propose :)

    – Fanis Tsatsaronis
    Mar 8 at 12:08
















Thanks for your response.Unfortunately it isn't the actual FileStream path. FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);

– Fanis Tsatsaronis
Mar 8 at 11:46






Thanks for your response.Unfortunately it isn't the actual FileStream path. FileStream ImageStream = new FileStream("C:\Users\ttsa\Desktop\DocumentViewerTest\002544-20180907.tif", FileMode.Open, FileAccess.Read, FileShare.Read);

– Fanis Tsatsaronis
Mar 8 at 11:46














Is there any other function in your app, that is trying to reach the file shown in your error?

– Pookie
Mar 8 at 11:54





Is there any other function in your app, that is trying to reach the file shown in your error?

– Pookie
Mar 8 at 11:54













No i just use a button and the DocumentViewer and the case is when i push the button i want the tiff to be displayed in the DocumentViewer.I have uploaded all the code both .xaml and .cs if you want to try it for yourself.I am glad to hear if you have anything else to propose :)

– Fanis Tsatsaronis
Mar 8 at 12:08





No i just use a button and the DocumentViewer and the case is when i push the button i want the tiff to be displayed in the DocumentViewer.I have uploaded all the code both .xaml and .cs if you want to try it for yourself.I am glad to hear if you have anything else to propose :)

– Fanis Tsatsaronis
Mar 8 at 12:08

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55062144%2ferror-displaying-tiff-image-to-documentviewer-wpf-c%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived