10 Replies - 2162 Views - Last Post: 14 February 2012 - 02:50 PM Rate Topic: -----

#1 Ailaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 10-December 11

how to refer to USB drive....

Posted 12 February 2012 - 05:01 PM

While i have been working with my file I'm having to change the file directory wherever I am working. How do I save into a file on the USB by default?

In my program I refer to folders in the J:\ ...but if I'm work I change this to K drive....

I'm sending out USB's with my application to users. The app pulls in randomised images from file. and saves files in the USB again -


How do I overcome the above?

Is This A Good Question/Topic? 0
  • +

Replies To: how to refer to USB drive....

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,659
  • Joined: 02-June 10

Re: how to refer to USB drive....

Posted 12 February 2012 - 06:34 PM

Its just home and work computers, right? 2 PC's?

The simple, non-coding way is to go into DriveManagement and re-assign the letter on each of your 2 PC's so the USB stick(s) are always the same letter on each computer. Bing bang boom, you're done in 3 minutes.

Attached Image

Otherwise there are a ton of tutorials if you just google "C# detect flashdrive". Since you didn't show any effort to code this, I'm assuming you haven't really tried to find an example and just hoped we'd hand it to you on a plater with minimal effort.


Please take a try at coding a solution now that you have been given a direction to research. Once you have updated your code if you are still having issues please post in this thread rather than starting a new one.

This post has been edited by tlhIn`toq: 12 February 2012 - 06:35 PM

Was This Post Helpful? 0
  • +
  • -

#3 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: how to refer to USB drive....

Posted 12 February 2012 - 09:56 PM

Quote

Otherwise there are a ton of tutorials if you just google "C# detect flashdrive". Since you didn't show any effort to code this, I'm assuming you haven't really tried to find an example and just hoped we'd hand it to you on a plater with minimal effort.

1. We're working in VB.Net
2. Ailaz never asked for a platter - he's a good OP.
If the application is being run from the USB, and you want to copy things to the USB you can copy the files into a path on the USB like so:
Application.StartupPath & "\images"

In conjunction with My.Computer.FileSystem.CopyFile()
Was This Post Helpful? 1
  • +
  • -

#4 Ailaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 10-December 11

Re: how to refer to USB drive....

Posted 13 February 2012 - 03:45 PM

View PosttlhIn`toq, on 13 February 2012 - 01:34 AM, said:

Its just home and work computers, right? 2 PC's?

The simple, non-coding way is to go into DriveManagement and re-assign the letter on each of your 2 PC's so the USB stick(s) are always the same letter on each computer. Bing bang boom, you're done in 3 minutes.

Attachment change_drive_letter.jpg

Otherwise there are a ton of tutorials if you just google "C# detect flashdrive". Since you didn't show any effort to code this, I'm assuming you haven't really tried to find an example and just hoped we'd hand it to you on a plater with minimal effort.


Please take a try at coding a solution now that you have been given a direction to research. Once you have updated your code if you are still having issues please post in this thread rather than starting a new one.

    Thank you for your reply :bigsmile:


    I'm using vb.net
  • The application will be sent out to 20 users on a USB stick ...so 22 PC's :)
  • I did do some research ...but would have been posting other peoples codes...I feel like a fraud when I do that
  • I do like to try ...
    Will post the code I used when I log off mac..


View PostjimmyBo, on 13 February 2012 - 04:56 AM, said:

Quote

Otherwise there are a ton of tutorials if you just google "C# detect flashdrive". Since you didn't show any effort to code this, I'm assuming you haven't really tried to find an example and just hoped we'd hand it to you on a plater with minimal effort.

1. We're working in VB.Net
2. Ailaz never asked for a platter - he's a good OP.
If the application is being run from the USB, and you want to copy things to the USB you can copy the files into a path on the USB like so:
Application.StartupPath & "\images"

In conjunction with My.Computer.FileSystem.CopyFile()


Thanks JimmyBo :^:

I just noticed .... :smile2:

he's a good OP.
... :no: She :)

This post has been edited by Ailaz: 13 February 2012 - 03:38 PM

Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8939
  • View blog
  • Posts: 33,521
  • Joined: 12-June 08

Re: how to refer to USB drive....

Posted 13 February 2012 - 03:50 PM

Wait. .what? The user will run this from the usb and you need a path to that usb, right?

Wouldn't something like

Windows.Forms.Application.StartupPath 
be enough?
Was This Post Helpful? 0
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,659
  • Joined: 02-June 10

Re: how to refer to USB drive....

Posted 13 February 2012 - 04:09 PM

View Postmodi123_1, on 13 February 2012 - 04:50 PM, said:

Wait. .what? The user will run this from the usb and you need a path to that usb, right?

Wouldn't something like

Windows.Forms.Application.StartupPath 
be enough?



View PostjimmyBo, on 12 February 2012 - 10:56 PM, said:

If the application is being run from the USB, and you want to copy things to the USB you can copy the files into a path on the USB like so:
Application.StartupPath & "\images"

In conjunction with My.Computer.FileSystem.CopyFile()

Was This Post Helpful? 1
  • +
  • -

#7 Ailaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 10-December 11

Re: how to refer to USB drive....

Posted 13 February 2012 - 04:42 PM

My image files are in a different directory. So I used:

Dim driv As String=Microsoft.VisualBasic.Left(Directory.GetCurrentDirectory(),3)

so where needed I've used it in the below form for csv

String.Concat(driv, "images\UBM1.csv")
...

and for images
String.Concat(driv, "UBMGrading\Iris\IP")
.....

So driv is replacing J:\ or whatever drive:\
Eventually I will have about 250 images ...so I chose to put them in a file. With the images I was using as a test set (approx 70 images ..saving in the application file seemed slow. Seems to be running quicker with images pulled in from file directory.



Thanks All :bananaman:

This post has been edited by Ailaz: 14 February 2012 - 02:40 PM

Was This Post Helpful? 0
  • +
  • -

#8 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: how to refer to USB drive....

Posted 13 February 2012 - 07:02 PM

A better choice for concatenating file paths is the IO.Path.Combine method.

This post has been edited by _HAWK_: 14 February 2012 - 07:18 AM

Was This Post Helpful? 2
  • +
  • -

#9 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: how to refer to USB drive....

Posted 14 February 2012 - 12:38 AM

[quote name='Ailaz' date='14 February 2012 - 08:45 AM' timestamp='1329173118' post='1551205']

View PosttlhIn`toq, on 13 February 2012 - 01:34 AM, said:

Its just home and work computers, right? 2 PC's?

The simple, non-coding way is to go into DriveManagement and re-assign the letter on each of your 2 PC's so the USB stick(s) are always the same letter on each computer. Bing bang boom, you're done in 3 minutes.

Attachment change_drive_letter.jpg

Otherwise there are a ton of tutorials if you just google "C# detect flashdrive". Since you didn't show any effort to code this, I'm assuming you haven't really tried to find an example and just hoped we'd hand it to you on a plater with minimal effort.


Please take a try at coding a solution now that you have been given a direction to research. Once you have updated your code if you are still having issues please post in this thread rather than starting a new one.

    Thank you for your reply :bigsmile:


    I'm using vb.net
  • The application will be sent out to 20 users on a USB stick ...so 22 PC's :)
  • I did do some research ...but would have been posting other peoples codes...I feel like a fraud when I do that
  • I do like to try ...
    Will post the code I used when I log off mac..


View PostjimmyBo, on 13 February 2012 - 04:56 AM, said:

Thanks JimmyBo :^:

I just noticed .... :smile2:

he's a good OP.
... :no: She :)

Sorry… I'll remember for next time! :stupid:

This post has been edited by jimmyBo: 14 February 2012 - 12:39 AM

Was This Post Helpful? 0
  • +
  • -

#10 Ailaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 10-December 11

Re: how to refer to USB drive....

Posted 14 February 2012 - 02:44 PM

View Post_HAWK_, on 14 February 2012 - 02:02 AM, said:

A better choice for concatenating file paths is the IO.Path.Combine method.


thanks Hawk....used it elsewhere in application too.

This post has been edited by Ailaz: 14 February 2012 - 02:49 PM

Was This Post Helpful? 0
  • +
  • -

#11 Ailaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 10-December 11

Re: how to refer to USB drive....

Posted 14 February 2012 - 02:50 PM

- @ Jimmy Bo :). It's ok I'm not scarred by it!

This post has been edited by Ailaz: 14 February 2012 - 02:50 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1