VB.Net: Getting File Path from Data Files In Project

Bob

I'm creating a prototype that I will be putting on a CD and handing off to someone in Visual Studio. In this prototype, I have multiple Excel spreadsheets that I use for data.

I have the following line of code:

dataWorkBook = dataWorkbookApp.Workbooks.Open("C:\Users\me\Desktop\Task\Prototype Data.xlsx")

Which opens one of the Excel Spreadsheets. This obviously wont work when I put it on a CD. I have created a Folder in my Visual Studio Project ("Data") and put all data files I have in it.

My questions is how do I get the file path to those files and put it in the above code?

jmcilhinney

If you have added a folder named "Data" to your project and put all your data files in there, then set their Build Action property Content and their Copy Local property to Copy Always or Copy If Newer, that "Data" folder will be in the program folder along with the EXE. In that case, assuming a Windows Forms application, you can use Application.StartupPath to get the root folder path:

dataWorkBook = dataWorkbookApp.Workbooks.Open(IO.Path.Combine(Application.StartupPath, "Data\Prototype Data.xlsx"))

That will work while debugging or in the final release, because it's always relative to the program folder.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Getting File Path in .NET From Code Behind

From Dev

while deleting image from path getting error in vb.net

From Dev

VB.NET get path from the file the user opened

From Dev

Getting path directory from input file ASP.Net

From Dev

VB.net Find And Replace from Data in a DataGridView in a text file

From Dev

Getting the file extension of a filename in VB.NET?

From Dev

getting data from file

From Dev

Vb.net - Getting time from website

From Dev

VB.Net Getting Value from JSON

From Dev

Getting file path in java transformer from project using servlet in mule esb

From Dev

Getting File path from a open file dialog

From Dev

VB.NET Data getting cleared from the modal popup on parent window post back

From Dev

Unable to create tar file of files from specific folder . Getting wrong path after extraction

From Dev

Filter files from directory vb.net

From Dev

ASP.NET Web Forms - Getting Path to To a File From a C# Class

From Dev

Getting the File Path from a FileUpload dialog in ASP.NET throws FileNotFound Exception

From Dev

Getting absolute file path from function handle

From Dev

Getting audio file path or URI from mediastore

From Dev

getting data from json file

From Dev

How do I Insert 2 button in every row of data in the datagridview in VB.net getting its data from mysql

From Dev

Getting /data/data/my.app/files path programmatically?

From Dev

reading a file from a relative path in a maven project

From Dev

cannot insert path file address to mysql using vb.net

From Dev

File.Create(path) error VB.NET

From Dev

Read data from a database in vb.net

From Dev

Inserting Data in sql database vb.net is not getting stored

From Dev

Inserting Data in sql database vb.net is not getting stored

From Dev

Programatically retrieve the full data directory path in VB.NET

From Dev

File path error while adding localization files to project

Related Related

  1. 1

    Getting File Path in .NET From Code Behind

  2. 2

    while deleting image from path getting error in vb.net

  3. 3

    VB.NET get path from the file the user opened

  4. 4

    Getting path directory from input file ASP.Net

  5. 5

    VB.net Find And Replace from Data in a DataGridView in a text file

  6. 6

    Getting the file extension of a filename in VB.NET?

  7. 7

    getting data from file

  8. 8

    Vb.net - Getting time from website

  9. 9

    VB.Net Getting Value from JSON

  10. 10

    Getting file path in java transformer from project using servlet in mule esb

  11. 11

    Getting File path from a open file dialog

  12. 12

    VB.NET Data getting cleared from the modal popup on parent window post back

  13. 13

    Unable to create tar file of files from specific folder . Getting wrong path after extraction

  14. 14

    Filter files from directory vb.net

  15. 15

    ASP.NET Web Forms - Getting Path to To a File From a C# Class

  16. 16

    Getting the File Path from a FileUpload dialog in ASP.NET throws FileNotFound Exception

  17. 17

    Getting absolute file path from function handle

  18. 18

    Getting audio file path or URI from mediastore

  19. 19

    getting data from json file

  20. 20

    How do I Insert 2 button in every row of data in the datagridview in VB.net getting its data from mysql

  21. 21

    Getting /data/data/my.app/files path programmatically?

  22. 22

    reading a file from a relative path in a maven project

  23. 23

    cannot insert path file address to mysql using vb.net

  24. 24

    File.Create(path) error VB.NET

  25. 25

    Read data from a database in vb.net

  26. 26

    Inserting Data in sql database vb.net is not getting stored

  27. 27

    Inserting Data in sql database vb.net is not getting stored

  28. 28

    Programatically retrieve the full data directory path in VB.NET

  29. 29

    File path error while adding localization files to project

HotTag

Archive