Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
i want to create a folder with name curent date and time then save an image to the created folder in C#

i have tried something but its creating folder but images are not saving in that folder

Screenshot-58 — ImgBB[^]

What I have tried:

Screenshot-56 — ImgBB[^]

Screenshot-57 — ImgBB[^]
Posted
Updated 22-Dec-22 3:14am
v2
Comments
Richard Deeming 22-Dec-22 8:33am    
There's a secret error somewhere in your secret code. You need to fix that.

Seriously, nobody can help you fix code we cannot see. Click the green "Improve question" link and update your question to include the relevant parts of your code.

(And no, blurry screen-shots of code hosted on an external site do not count.)

This is REALLY EASY to diagnose. Set a breakpoint in the code that generates the filepath for the image. Run the code. When the debugger stops the code at the breakpoint, hover the mouse over the variable you're building the filepath in. Does that path look correct? Probably not. Now you have to go backwards through the code and figure out why the path isn't what you expected.

From a quick glance at the screenshots of your code (NEVER POST CODE AS SCREENSHOTS!), you created a folder with the name "Todaysdate", but did not use the folder path that was created in your filepath for saving the file. YOu're rebuilding the path to the file again, and doing it in a way that does not match the original path. Instead of rebuilding the path again, just use the folderpath you already created.
 
Share this answer
 
v2
Comments
adriancs 24-Dec-22 11:23am    
Oh yeah, may I attach (add-on) a hint to this answer :D, try `MessageBox.Show(path);` and see
We can't see your code, we can't access your HDD, and we can;t read your mind: we can't help you as a result!

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900