4 Replies - 817 Views - Last Post: 10 June 2014 - 08:13 AM Rate Topic: -----

#1 pensioenvizier   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 64
  • Joined: 16-April 14

directory accesable for multiple computers

Posted 10 June 2014 - 03:29 AM

Hi Guys,

For my application i'm using an excel sheet, which calculates someone's total expenditure.

The values from this excel sheet im importing it into my vb.net application.
Now im using the filename:

fName = "C:\Users\Ruud\Desktop\vb\Inventarisatie uitgaven sjabloon apr 2014.xls"



This filename is adjusted for my pc. But i would like to use my application on more computers.
Does anyone know a solution to make the filename more accesable for multiple computers?

Thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: directory accesable for multiple computers

#2 smohd   User is offline

  • Critical Section
  • member icon


Reputation: 1825
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: directory accesable for multiple computers

Posted 10 June 2014 - 03:49 AM

You can use GetCurrentDirectory() to get the current directory of the application. Or you can use My Documents or any of the spceial directories.

This post has been edited by smohd: 10 June 2014 - 03:49 AM

Was This Post Helpful? 1
  • +
  • -

#3 pensioenvizier   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 64
  • Joined: 16-April 14

Re: directory accesable for multiple computers

Posted 10 June 2014 - 07:11 AM

If i use the read all method i get this error.

Edit:
I had to replace mydocuments with desktop..

        Dim filename As String
        Dim patients As String
        filename = My.Computer.FileSystem.SpecialDirectories.Desktop & "\" & "Inventarisatie uitgaven sjabloon apr 2014.xls"
        patients = My.Computer.FileSystem.ReadAllText(filename)



Will my application work on every other computer if i place the excel sheet "Inventarisatie uitgaven sjabloon apr 2014.xls" on the desktop?

Attached image(s)

  • Attached Image

This post has been edited by pensioenvizier: 10 June 2014 - 07:21 AM

Was This Post Helpful? 0
  • +
  • -

#4 smohd   User is offline

  • Critical Section
  • member icon


Reputation: 1825
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: directory accesable for multiple computers

Posted 10 June 2014 - 07:27 AM

That means the file you are trying to read in not in the location you specified: C:\Users\Ruud\Documents. Did you check if the file exist?

For a windows system, which has a desktop in it, then yes. Special directory will return the path to the specified special directory regardless of the user loggedin. But why you want to show in the desktop? I think in documents works better..
Was This Post Helpful? 1
  • +
  • -

#5 Sheepings   User is offline

  • D.I.C Lover
  • member icon

Reputation: 263
  • View blog
  • Posts: 1,384
  • Joined: 05-December 13

Re: directory accesable for multiple computers

Posted 10 June 2014 - 08:13 AM

The app_data folders were made specifically for this purpose and you should be using those if your application is using application files. Not your desktop though. The error reflects that the file was either moved or doesn't exist. This has been tested by myself and does work. Please place the file in the location you are trying to read.
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim MyFileName As String
        Dim MyFileContents As String
        MyFileName = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\" & "Inventarisatie uitgaven sjabloon apr 2014.xls"
        MyFileContents = My.Computer.FileSystem.ReadAllText(MyFileName).ToString()
        MsgBox(MyFileContents)
    End Sub


Might i add that your code in the screenshot is looking in your documents but your quoted code is saying to look in your desktop for the file location.

This post has been edited by Sheepings: 10 June 2014 - 08:14 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1