I have one project and in this project I want to save picture to application path and save the path to database as string and retrieve the image from the application path.
Can u give me some idea about it...
i am using vb.net as frontend and ms access database
Getting the Application Path:
My.Application.Info.DirectoryPath
Combining Paths:
[System.IO.]Path.Combine(Path1, Path2)
Images:
yourImageObject.Save(yourPath)
yourImageObject = Image.FromFile(yourPath)
Related
I'm webscrapping data about ski resorts from a site, also getting some pictures. I am saving those pictures in a folder and after that i'm getting them in SQLite database through an imageField.
The bad part is that they don't work
directory = r'C:\Users\tiberiu.ghimbas\Documents\Resorts img5'
image_list = [cv2.imread(file) for file in
glob.glob(r'C:/Users/tiberiu.ghimbas/Documents/Resorts img5/*.png')]
This list is then looped and insertet item by item.
I'm doing all the correct settings for handling images and media files.
I know that by going the classic way of uploading images through a form will get you in the database the path to the image from de media/"upload_to = 'filename'" folder but going by my way i'm getting only them image name.
How can i solve that ?
I want to make a simple .exe application in vb.net. The application wont have an installation just pure run on .exe file .
Application has one form and two pictures. When i set the option on image to build action - compile
Unable to open module file 'C:\Users\t3cho\documents\visual studio 2013\Projects\Apps\Apps\Resources\power.png': System Error &H80041feb&
Is there any other way to make an .exe file with images without installation or additional folders.
The easiest way to include images (and other types of resources) into the application is to right-click the project, go to the "Resources"-Tab and add the image there. You can change its name to e.g. MyEmbeddedImage and access it like this
Dim img As Image = Properties.Resources.MyEmbeddedImage
or
Dim img As Image = My.Resources.MyEmbeddedImage
This automatically sets the Build Action to None.
Note: This approach is type-safe and you will get errors at compile time, if the image is missing.
See: My.Resources Object and How to: Add or Remove Resources
If you still want to embed the image "manually", you must set the Build Action to Embedded Resource and access it as #Icemanind describes.
Yes. It's called embedded resources. Set your image's Build Action to Embedded Resource. You can then get the image at runtime like so:
Try
_assembly = [Assembly].GetExecutingAssembly()
_imageStream = _assembly.GetManifestResourceStream("MyNameSpace.MyImage.png")
' Do something with _imageStream
Catch ex As Exception
' Resource not found or something went wrong
End Try
I place a simple fileupload control in my webform application. firstly user have to login and his login username is stored in a session. then user have option to upload his pic. I place an image control.If pic is available it is shown in Image control. My fileupload code is
string sp = fileuploadpanno.FileName;
string fn = Server.MapPath("~/panno/" + sp);
fileuploadpanno.PostedFile.SaveAs(fn);
My question is how to save this file into database. I am using mysql database.
You could potentially store the image in the database directly by first converting it to a BLOB.
A more widely used practice is to store the image in a directory/location such as App_Data or Temp and then store the image name in your mysql database. Then when you want to reference the image in your web application you can just use a normal image tag with the source being the location of the image concatenated to the image name you retreive from your database.
So for example if I have a directory /App_Data/Images/
And I store an image name in my database called my_image.jpg
After moving the image above to the directory above (save it in this location) I can then reference it by appending the image name to the location /App_Data/Images/my_image.jpg
I have got a app with the getItemsAsync()-method returning a file-object for a picture chosen by the user with a file picker. Now I would like to get the folder-object of the folder which contains the image to make the user able to switch between the pictures in that folder without using the filepicker again.
The path is available upon return from the file picker. See:
Docs for StorageFile
You can in turn then call
Windows.Storage.StorageFolder.getFolderFromPathAsync(path)
.done( /* Your success and error handlers */ );
to get you the StorageFolder from that path.
Docs for GetFolderFromPathAsync()
if the app likely want to 'access' any file in the select folder, using FolderPicker is probably right. otherwise, the app will likely not have access to all files in the folder.
I'm new to Windows 8 app development. I'm trying to port a old application I wrote in .NET. This application uses base data which is stored as four XML files that were added to the project as "Ressource" and deserializes them using the System.Xml.Serialization.XmlSerializer.
What would be the best way to ship data like this with an Windows 8 Store App? Just put them in the Assets Folder?
What is the best way to load and bind data like this in an Windows 8 app?
I'm grateful for everything you can give me, a direct answer, helpful links or an video on data loading and binding in Windows 8 ...
You can use resources in store app, here is the example :
public static string GetXmlContentsFromResource(Assembly asm, string dataName)
{
string contents = "";
Stream stream = asm.GetManifestResourceStream(asm.GetName().Name + "." + dataName);
using (StreamReader reader = new StreamReader(stream))
{
contents = reader.ReadToEnd();
}
return contents;
}
You should add XML files to solution and mark it as "Embedded Resource", and if you put XML files in subdirectory, for example if folder is named Data and xml file is Data1.xml then you should send parameter dataName to above method like this "data.Data1.xml".
For Data Binding best aproach is to deserialize that XML to object or list of objects that reflects XML contents.
What would be the best way to ship data like this with an Windows 8 Store App? Just put them in the Assets Folder?
Yes, put them in your assets folder. Be sure to set the build properties to "Content" + "Copy To Output". Once you have done this, you can access them from your app using the following url: ms-appx:///Assets/myxmlfile.xml
For example:
StorageFile xmlFile = await StorageFile.GetFileFromApplicationUriAsync
(new Uri("ms-appx:///Assets/myxmlfile.xml"));
The above gives you a file object that you can use to read your file. Obviously, since you are reading from the Assets folder, your file will be read-only.
What is the best way to load and bind data like this in an Windows 8 app?
As to data binding, that is probably a bit too large to cover in one answer. You might want to take a look at this Windows 8 Data Binding Sample.