C
C#2mo ago
J.W.H

isa direcotry not a file error

system.io.ioexception: 'the target file 'c:\users\james\onedrive\desktop\hash table login function\hash table login function\bin\debug\net8.0-windows\userfiles\123' is a directory, not a file.' i get this from this
No description
55 Replies
leowest
leowest2mo ago
according to https://learn.microsoft.com/en-us/dotnet/api/system.io.file.copy?view=net-8.0 destination needs to include the filename
leowest
leowest2mo ago
No description
J.W.H
J.W.H2mo ago
"boom.wav" is the filename i want to move
leowest
leowest2mo ago
that's great but you're not including it you're combining 2 directories and not adding the filename at the end
J.W.H
J.W.H2mo ago
how would i include it because i thought i was already doing that
leowest
leowest2mo ago
so in your code what line is combining the directories
J.W.H
J.W.H2mo ago
No description
J.W.H
J.W.H2mo ago
353 thats what combineds the paths right?
leowest
leowest2mo ago
ok, and what happens if u add 342 to it
J.W.H
J.W.H2mo ago
that should be the file it copyies to the destinationwavfilepath i really dont get how its not doing that
leowest
leowest2mo ago
add line 342 to line 353 what it would look like? because right now it does not have the file
J.W.H
J.W.H2mo ago
so how do i make it have the file? beacuse surely adding it to 353 would make it say bin/net8.0/username/boom.wav would that be it
leowest
leowest2mo ago
yes[
J.W.H
J.W.H2mo ago
so i should combine to destination?
leowest
leowest2mo ago
yes that is what it says in there
leowest
leowest2mo ago
No description
J.W.H
J.W.H2mo ago
so with line 355 i can just get rid of that right?
leowest
leowest2mo ago
what you mean?
J.W.H
J.W.H2mo ago
when i run the code the same error comes up but highlights line 355
leowest
leowest2mo ago
do u have a file with the name boom.wav in that folder? go and make sure if u do then u need to add at the end of line 355 true
J.W.H
J.W.H2mo ago
no the bbom.wav is not in that folder
leowest
leowest2mo ago
what is the value of both in line 355
J.W.H
J.W.H2mo ago
sourcewavfile = the name of the wave file i want to move and destination is the file i want to move that file to
leowest
leowest2mo ago
No description
leowest
leowest2mo ago
print it out like this make sure u have the right path on both
J.W.H
J.W.H2mo ago
source = "boom.wav destination = C:\Users\James\OneDrive\Desktop\hash table login function\hash table login function\bin\Debug\net8.0-windows\UserFiles\123 when i run it through code it prints this UserFiles\123\Boom.wav
leowest
leowest2mo ago
then u have not updated your code can u show me what your code looks like after the changes I asked u to do
J.W.H
J.W.H2mo ago
No description
leowest
leowest2mo ago
:catfacepalm:
J.W.H
J.W.H2mo ago
hahahahahahha i beg help me its 5am for me
leowest
leowest2mo ago
I asked u, add the file name to line 353 u made a new variable all u had to do is add
J.W.H
J.W.H2mo ago
how do i add it
leowest
leowest2mo ago
not create any new line
J.W.H
J.W.H2mo ago
is just another comma
leowest
leowest2mo ago
No description
leowest
leowest2mo ago
same way u added those
leowest
leowest2mo ago
No description
leowest
leowest2mo ago
what is your language
J.W.H
J.W.H2mo ago
c#
leowest
leowest2mo ago
no the language u speak your mother language
J.W.H
J.W.H2mo ago
english
leowest
leowest2mo ago
ok then u should be able to understand what is in red right so you need to add the file name
J.W.H
J.W.H2mo ago
No description
J.W.H
J.W.H2mo ago
like this? ive added the file name there
MODiX
MODiX2mo ago
No description
leowest
leowest2mo ago
that is all u had to do nothing else
J.W.H
J.W.H2mo ago
No description
leowest
leowest2mo ago
...
J.W.H
J.W.H2mo ago
what is the other bit i add to the file.copy though
leowest
leowest2mo ago
what u had before this
leowest
leowest2mo ago
this was the ONLY thing u had to change
No description
leowest
leowest2mo ago
nothing else
J.W.H
J.W.H2mo ago
im sorry but thankyou for putting up with me
leowest
leowest2mo ago
you dont need to be sorry u just need to look carefully at what the code is telling u and read the docs like everytime as ur learning u need to do something if you need to use "c# Path.Combine" u can google it an it should give u the microsoft docs right at the top so u can see what it does https://learn.microsoft.com/en-us/dotnet/api/system.io.path.combine?view=net-8.0#system-io-path-combine(system-string-system-string-system-string) then take a bit of time to read how it works experiment print it to the console $close
MODiX
MODiX2mo ago
If you have no further questions, please use /close to mark the forum thread as answered