| public static void OpenFileWithDefaultApplication(string fullfileLocationAndName, byte[] data) |
| { |
| try |
| { |
| System.IO.FileStream fs = new System.IO.FileStream(fullfileLocationAndName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite); |
| fs.Write(data, 0, data.Length - 1); |
| fs.Close(); |
| fs.Dispose(); |
| System.Diagnostics.Process.Start(fullfileLocationAndName); |
| } |
| catch (Exception ex) |
| { |
| MessageBox.Show("There was an error opening the file: " + ex.Message); |
| } |
| } |
Showing posts with label Open Using Default Application. Show all posts
Showing posts with label Open Using Default Application. Show all posts
Monday, May 14, 2012
.NET C# Create a file and open it using Default Application Type
Sunday, May 6, 2012
JAVA Open a file using the default application editor.
// Example Foo.xls will be opened with Excel
// Make sure to import the class java.awt.Desktop
public static void OpenFile(String filename){
try{
// Check if class 'Desktop' is supported on the platform
if (Desktop.isDesktopSupported()) {
Desktop.getDesktop().open(new File(filename));
}else{
System.out.println("Class Desktop is unsupported");
}
} catch (Exception ex){
System.out.println("Error opening "+ filename);
}
}
// Make sure to import the class java.awt.Desktop
public static void OpenFile(String filename){
try{
// Check if class 'Desktop' is supported on the platform
if (Desktop.isDesktopSupported()) {
Desktop.getDesktop().open(new File(filename));
}else{
System.out.println("Class Desktop is unsupported");
}
} catch (Exception ex){
System.out.println("Error opening "+ filename);
}
}
Subscribe to:
Posts (Atom)