|
I am developping a window form application in VB.NET.
The program will run from a CD.
The hierarchy of the files is as following:
[Drive Letter]:\AppName.exe
[Drive Letter]:\PDF\PDFName.pdf
I would like to open the pdf file.
IN VB6 I had to use:
1. Findexecutable API that return the path of the acrobat program that open the PDF.
2. Shell function to open the file.
3. App.path & "\PDF\PDFName.pdf" to locate the file on the CD
Please help in VB.NET
Eric H.
|
|
|
|
|
All you have to do is launch the PDF file and it'll open in the default PDF viewer. You can get the drive letter very easily using Application.StartupPath:
Dim appPath As String = Application.StartupPath
Dim pathToPdf As String = Path.Combine(Path.GetPathRoot(appPath), "PDF\PDFName.pdf")
DIm proc As Process = Process.Start(pathToPdf)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks, what is Path, I get an error that is not declared.
Eric H.
|
|
|
|
|
All you have to do is put the cursor on "Path" and hit F1.
Put this at the top of your code:
Imports System.Io
<div class="ForumSig"><font color="Blue">Dave Kreskowiak
Microsoft MVP - Visual Basic</font>
</div>
|
|
|
|
|
Thank you all, it works
Eric H.
|
|
|
|
|
I m writing this code in VB.NET web application to set the MIME type for some particular file extensions.It working fine but what
i want to do is i don't want the web application I want this code in vb.net 1.1 console application.Is it possible to use httpresponse in
console application?
Dim fs As System.IO.FileStream = Nothing
fs = System.IO.File.Open("C:\...\test.zip", System.IO.FileMode.Open)
Dim btFile(fs.Length) As Byte
fs.Read(btFile, 0, fs.Length)
fs.Close()
Response.AddHeader("Content-disposition", "attachment; filename=" + "test.zip")
Response.ContentType = "application/octet-stream"
Response.BinaryWrite(btFile)
Response.End()
|
|
|
|
|
No, you don't have a Response object in a console application, as a console application is not creating a response to send to a browser.
What is it that you want to do with the data that you have read from the file?
---
single minded; short sighted; long gone;
|
|
|
|
|
I am getting attachments with a mail which are saved onto the local disk and what i want to do is, from local disk it should read the file byte by byte and set the MIME type of these attachments so tht if there is a zip file it should ask for unzip, if its an mp3 it will ask for open,close or save, and similarly do for different file extensions!
|
|
|
|
|
You can't set the mime type of individual files. The type of the file is determined by the file extension, and how the file should be handled is already defined in the file type settings of the system.
---
single minded; short sighted; long gone;
|
|
|
|
|
so what can i do to open files according to their file extensions like for image file the image should get opened and for zip open,save,cancel etc.option should be asked...........
i m getting garbage output while opening image and zip files..........
so is there any option to recover from this ?
in VB.NET 1.1 console application?
|
|
|
|
|
What are you using to open the files?
Use Process.Start to make the system choose the registered program for each file type to open it.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello everyone. I am new to VB and its a little different to embedded C that I am used to. I am trying to write some macros in Excel to automate some of my business practice. Here is a piece of code that is giving me grief at the moment.
For i = 1 To 500
If Worksheets("Prices").Cells(i, 7) = 2 Then
Sheets(5).Cells(1, i) = Sheets(1).Cells(i, 1)
End If
Next i
Trying to get that code to copy one cell to another if the statement above is true. The i is defined as an integer (global).
The compiler spits it at this line. All the code before this runs fine...
Sheets(5).Cells(1, i) = Sheets(1).Cells(i, 1)
Can anyone tell me what the problem is? I would assume its very easy to solve, just cant see what im doing wrong and I cant find info on the net.
Thanks in advance.
~Todd
|
|
|
|
|
Try appending .Value to eaceh cell object:
Sheets(5).Cells(1,i).Value = Sheets(1).Cells(i,1).Value
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I had one file template type "file_1.xls".
I need open file this and insert data in sheet of file. But at present because of me haven't been processed.
Can you help me and give a examples to me ?
|
|
|
|
|
You can use ODBC connection for that. By using Transact SQL command like UPDATE or INSERT you will be able to print in Excel file. You can search web for an appropriate ODBC connection to a file code.
B.B.
|
|
|
|
|
|
I had one file template type "file_1.xls".
I need open file this and insert data in sheet of file. But at present because of me haven't been processed.
Can you hepl me and give a examples to me ?
|
|
|
|
|
Hi,
Is it possible to programmatically add menu items and sub menus at run time?
I want to read in the contents of a database when my form is loaded, and add two of the database columns to my menu strip.
At design time, I've added a "View" menu. One of the options beneath it is, "Filter 1", and another is "Filter 2".
I want the column 0 contents of my database to populate a sub menu off the "Filter 1" option, and my column 1 contents to populate a sub menu off "Filter 2".
I'm using VB.NET 2005 Express.
|
|
|
|
|
Yes,
You have to define a new MenuItem object and then add it to another MenuItems items collection. You then also have to enable the required event handlers.
|
|
|
|
|
I have this
Dim img As Image = Image.FromFile("c:\Pics\Frame.gif")
Now how do I place it on the form?
|
|
|
|
|
You would have to use a picture box, like so:
<br />
Dim PicBox As New PictureBox<br />
PicBox.ImageLocation = "c:\Pics\Frame.gif"<br />
Me.Controls.Add(PicBox)<br />
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
A picture box is second easiest, easiest is to set the background image property of the form to the image, but that is harder to control if you don't want it over the entire form. You get the most control by drawing it yourself in a paint message handler.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for that,
You get the most control by drawing it yourself in a paint message handler.
Just need to go and find out how.
|
|
|
|
|
I am trying to get the DataGridView to show a Column Selected. I want the user to be able to select a column and capture the index to that column??
|
|
|
|
|
You have to deal with DataGridTableStyle and DataGridColumnStyle . Useful hints here [^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|