Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
I want to store only file name for example rose.jpg but in my code it save as D:\image\rose.jpg
How can i save only file name in db??
Posted 28-Sep-12 8:54am
Comments
RaisKazi at 28-Sep-12 14:55pm
   
And from where that full path of image is comming?
Yasir Farooq at 28-Sep-12 15:00pm
   
upload a image from filedialog. store image and image name in database.
Sergey Alexandrovich Kryukov at 28-Sep-12 15:14pm
   
Only? What's the problem? Isn't file name is just a string? :-)
--SA
Yasir Farooq at 28-Sep-12 15:19pm
   
I apply a query after opening filedialog it automatic save image and image address in database
just like in image column 'binary data' and in Name column C:\documents\images\*.jpg
i want to save image name like *.jpg in Name column.
Sergey Alexandrovich Kryukov at 28-Sep-12 16:10pm
   
OK, save it if you want, why not?
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Use the FileInfo[^] class and save the Name[^] property to the database.
  Permalink  
Comments
Maciej Los at 28-Sep-12 16:10pm
   
Short and to the point, my 5!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

First of all, Marcus Kramer answer is very good!
Secondly: If you want to achieve that by MS SQL Server site, have a look here: Get filename from filepath[^]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 595
1 OriginalGriff 295
2 CPallini 210
3 PIEBALDconsult 150
4 Fredrik Bornander 140
0 OriginalGriff 5,835
1 Sergey Alexandrovich Kryukov 5,263
2 CPallini 4,750
3 George Jonsson 3,227
4 Gihan Liyanage 2,487


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100