Author Topic: COPY FILE  (Read 2783 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
COPY FILE
« on: February 24, 2010, 03:36:13 PM »
I must be lost in cyberspace b/c I can't make a simple file copy.  I am thinking it might be the name of the file i.e. "4236.20.xlsx" as an example. this is what I was trying
Code: [Select]
                    string filName = @"R:\000-Hall\" + txtProjNum.Text.ToString() + "\\" + txtProjNum.ToString() + ".xlsx";
                    System.IO.File.Copy("R:\\000-Hall\\original.xlsx", filName, true);

for some reason, the text box.tostring isn't working right, or Im way off.

Any ideas?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Glenn R

  • Guest
Re: COPY FILE
« Reply #1 on: February 24, 2010, 03:48:47 PM »
For a start, there's no need to call ToString() on a text object as it's already a string..just use this:

Code: [Select]
txtProjNum.Text

I noticed you're using it twice - I assume the project name forms the sub-folder as well as the ultimate file name?

Also, I suspect this:

Code: [Select]
txtProjNum.ToString()

should be this:

Code: [Select]
txtProjNum.Text

But without seeing the code, I'd be guessing. I suspect that calling txtProjNum.ToString() is giving you the class name of the TextBox control???

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: COPY FILE
« Reply #2 on: February 24, 2010, 03:50:05 PM »
Just a quick observation, if it's coming from a text box it's already text so you shouldn't need a conversion unless you wanted a number say.

Also, I'm not sure that txtProjNum.Text (should be the text box text) and txtProjNum.ToString() (this is the text box itself!) will work.

hth

ps. Glenn beat me to it :)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Glenn R

  • Guest
Re: COPY FILE
« Reply #3 on: February 24, 2010, 03:50:06 PM »
Put a MessageBox in for filName to find out...also, should that be fileName? ;-)

Glenn R

  • Guest
Re: COPY FILE
« Reply #4 on: February 24, 2010, 03:50:57 PM »
The 'ol double wammy!

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: COPY FILE
« Reply #5 on: February 24, 2010, 03:55:18 PM »
Glenn you are the MAN!  that was it, I was in fact calling the name of the control.  Funny thing was, VS was telling me that, but in the local window, all my vars looked good, so I couldn't figure out what was wrong.  Guess I couldn't see the forest for the trees.

thanks again
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: COPY FILE
« Reply #6 on: February 24, 2010, 03:57:33 PM »
Thanks for jumping in as well Mick.  Guess I just needed to step back and take a break from the code.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: COPY FILE
« Reply #7 on: February 24, 2010, 04:06:18 PM »
The real simple bugs are often the worst ones, you find yourself looking for something much more sinister .... then it hits you, Doh! :)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien