473,410 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

File Type associated program selector

Hello,

I have been working executeing files a user selects in a database, my
problem is that the file type may or may not be associated in the end users
system. How can I go about, when the user executes a file, if the file does
not have an associated application with it, show the window in windows that
asks the user what they would like to open it with? (The select program from
list window) thanks!

Nov 20 '05 #1
6 1115
Hi Brian,

I do not know if I am the only one who does not understand it.
Your talking about executing files in a database.
I thought you only could retrieve a file from a database.

However maybe I do not know something about processing a datatype in a
database, I am curious to know which datatype I than have to use.

Can you explain it a little bit more?

Cor
Nov 20 '05 #2
* "Brian Henry" <br**********@newsgroups.nospam> scripsit:
I have been working executeing files a user selects in a database, my
problem is that the file type may or may not be associated in the end users
system. How can I go about, when the user executes a file, if the file does
not have an associated application with it, show the window in windows that
asks the user what they would like to open it with? (The select program from
list window) thanks!


Set up a 'ProcessStartInfo', set its 'ErrorDialog' property to 'True'
and pass it to 'Process.Start'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
I'm reatrieveing the image data from SQL Server storeing it in a file then
trying to do a start process on it. I thin Herfried might of answered the
question for me :)

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
Hi Brian,

I do not know if I am the only one who does not understand it.
Your talking about executing files in a database.
I thought you only could retrieve a file from a database.

However maybe I do not know something about processing a datatype in a
database, I am curious to know which datatype I than have to use.

Can you explain it a little bit more?

Cor

Nov 20 '05 #4
Hi Brian,

Did you ever saw this sample of me, with that there is no saving to disk
needed?
The XML file is just to imitate a dataset from a database or a datareader.

Cor
Private abyt() As Byte
Private fo As New OpenFileDialog
Private sf As New SaveFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Reading a picture and put it in a bytearray
If fo.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(fo.FileName, _
IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
abyt = br.ReadBytes(CInt(fs.Length))
br.Close()
'just to show the sample without a fileread error
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
'writing a picture from a bytearray
If sf.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(sf.FileName, _
IO.FileMode.CreateNew)
Dim bw As New IO.BinaryWriter(fs)
bw.Write(abyt)
bw.Close()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button3.Click
'writing a bytearray to a dataset
Dim ds As New DataSet
ds.Tables.Add(New DataTable("Photo"))
ds.Tables(0).Columns.Add(New DataColumn("Sample"))
ds.Tables(0).Columns(0).DataType =
System.Type.GetType("System.Byte[]")
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(0)(0) = abyt
Dim sf As New SaveFileDialog
If sf.ShowDialog = DialogResult.OK Then
ds.WriteXml(sf.FileName, XmlWriteMode.WriteSchema)
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
'reading a picture from a dataset
Dim ds As New DataSet
If fo.ShowDialog = DialogResult.OK Then
ds.ReadXml(fo.FileName)
End If
abyt = CType(ds.Tables(0).Rows(0)(0), Byte())
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End Sub
///
Nov 20 '05 #5
it's not a picture image, but an image data type in SQL server, the actual
file could be anything from a picture or text document to a 100MB data
file...

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:u5**************@TK2MSFTNGP12.phx.gbl...
Hi Brian,

Did you ever saw this sample of me, with that there is no saving to disk
needed?
The XML file is just to imitate a dataset from a database or a datareader.

Cor
Private abyt() As Byte
Private fo As New OpenFileDialog
Private sf As New SaveFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Reading a picture and put it in a bytearray
If fo.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(fo.FileName, _
IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
abyt = br.ReadBytes(CInt(fs.Length))
br.Close()
'just to show the sample without a fileread error
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
'writing a picture from a bytearray
If sf.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(sf.FileName, _
IO.FileMode.CreateNew)
Dim bw As New IO.BinaryWriter(fs)
bw.Write(abyt)
bw.Close()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button3.Click
'writing a bytearray to a dataset
Dim ds As New DataSet
ds.Tables.Add(New DataTable("Photo"))
ds.Tables(0).Columns.Add(New DataColumn("Sample"))
ds.Tables(0).Columns(0).DataType =
System.Type.GetType("System.Byte[]")
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(0)(0) = abyt
Dim sf As New SaveFileDialog
If sf.ShowDialog = DialogResult.OK Then
ds.WriteXml(sf.FileName, XmlWriteMode.WriteSchema)
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
'reading a picture from a dataset
Dim ds As New DataSet
If fo.ShowDialog = DialogResult.OK Then
ds.ReadXml(fo.FileName)
End If
abyt = CType(ds.Tables(0).Rows(0)(0), Byte())
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End Sub
///

Nov 20 '05 #6
That is this sample for Brian, however the database is an XML dataset, but
that is the same for this.

It can even be a program, however keep in mind that it can become very slow
when you load huge files in your database.

Cor
it's not a picture image, but an image data type in SQL server, the actual
file could be anything from a picture or text document to a 100MB data
file...

Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jerry Gaspard | last post by:
I'd like to know how to open a document in a default app. like for example if I wanted to open a .txt document I'd like my program open notepad if it is the default for a windows machine text...
1
by: JerryP | last post by:
Hi Experts, from my program I offer the user to launch different files from a directory (normaly in this directory are .txt files) - but sometimes other files may be in there - so if my program...
2
by: david | last post by:
I have a basic problem about MS. I can not change the associated application with file type. I have done the following. go Tools -->Folder Options-->File Types. However, the buttons such as New,...
3
by: Shapper | last post by:
Hello, I created a script to upload a file. To determine the file type I am using userPostedFile.ContentType. For example, for a png image I get "image/png". My questions are: 1. Where can...
3
by: ciaran.mchale | last post by:
Hi folks, I downloaded the binary version of Xerces C++ 2.7.0 for Windows and am using it to help me get up to speed with XML and XML Schema. So please excuse me if this is a "novice" question....
1
by: Ganesh Muthuvelu | last post by:
Hello, Let us say I have a schema file like this sample below. How would I using ..NET classes be able to read this XSD file and get all the values for each element, such as "name", "type",...
2
by: sachinik19 | last post by:
Hi, xml file : ------------- <?xml version='1.0'?> <query xmlns='jabber:iq:privacy' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="jabber:iq:privacy privacy.xsd">...
1
by: Jane | last post by:
Is there a standard way that Windows programs open files? You know how you can associate a file type with a program, by telling Windows to always open a type with a program? Is the filename...
4
by: Sin Jeong-hun | last post by:
I already found that I have to use SHGetFileInfo to get the System's associated icon with that file. But what about I just want to get associated icon for some specific extensions? For example,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.