C# using the camera and storing it in a folder

Actually, this part of the post as most of my posts are just storing links and making comments for a future development of the real post…. Yeah, twitter and G+ are not receiving my stuff anymore, they say they are social media, no storage for links….so, here come some links for this Camera and storage program.

BTW, this is temporal, unless I die or I never find a real answer, usually happens the second one.




Enlace 1

Basic description about the GUI for the camera, it is the first program to make in order to understand how is going to work.

Enlace 2

At this point, I’ve not read it in all, but it appears to say something about the basic, the video and the storage, but it doesn’t say about how we should really store the data.

Enlace 3

This link is about auto uploading the photos taken.

Enlace 4

In this one we see how the files can be retrieved with ease.

Enlace 5

The best tutorial, actually, this is THE tutorial. I hope to see more about this author.

Enlace 6

Well this one and the next 3 are about storage, just storage. We need time to see what is all about, so I’m just storing for now.

Enlace 7


Enlace 8


Enlace 9

Recollection of several projects of UWP

Enlace 10

With this link we can save with a file picket

Enlace 11

With this we do it without a new interface asking shit about where to save it.





<Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”>

<Button Name=”Capture” Content=”Capture” HorizontalAlignment=”Left” Margin=”151,300,0,0″ VerticalAlignment=”Top” Height=”81″ Width=”159″ Click=”Capture_Click”/>


<Image Name=”image” HorizontalAlignment=”Left” Height=”503″ Margin=”523,106,0,0″ VerticalAlignment=”Top” Width=”634″/>


<Button x:Name=”Save” Content=”Save” HorizontalAlignment=”Left” Margin=”151,477,0,0″ VerticalAlignment=”Top” Height=”81″ Width=”159″ Click=”Save_Click”/>






MainPage : Page


StorageFile sf;

IRandomAccessStream rs;


public MainPage()






void Capture_Click(object sender, RoutedEventArgs e)



// Using the CameraCaptureUI object to invoke webcam and capture the image.

CameraCaptureUI cc = new

cc.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg; // Added support for Jpeg format, you can use any as you like.

cc.PhotoSettings.CroppedAspectRatio = new
Size(3, 4);

cc.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable;


// saving captured file in the StorageFile object, so that it can be later used to save the file in the specified location.

sf = await cc.CaptureFileAsync(CameraCaptureUIMode.Photo);

if (sf != null)


BitmapImage bmp = new

rs = await sf.OpenAsync(FileAccessMode.Read);


image.Source = bmp;




void Save_Click(object sender, RoutedEventArgs e)


// Adding try catch block in case of occurence of an exception



// Creating object of FileSavePicker and adding few values to the properties of the object.

FileSavePicker fs = new

fs.FileTypeChoices.Add(“Image”, new
List<string>() { “.jpeg” });

fs.DefaultFileExtension = “.jpeg”;

fs.SuggestedFileName = “Image” + DateTime.Today.ToString();

fs.SuggestedStartLocation = PickerLocationId.PicturesLibrary;


// Using storagefile object defined earlier in above method to save the file using filesavepicker.

fs.SuggestedSaveFile = sf;


// Saving the file

// var s = await fs.PickSaveFileAsync();


StorageFile mediafile = await Windows.Storage.KnownFolders.PicturesLibrary.CreateFileAsync(“fail.jpg”, Windows.Storage.CreationCollisionOption.ReplaceExisting);



//if (s != null)


using (var dataReader = new


await dataReader.LoadAsync((uint)rs.Size);

byte[] buffer = new


FileIO.WriteBytesAsync(mediafile, buffer);




catch (Exception ex)


var messageDialog = new
MessageDialog(“Something went wrong.”);

await messageDialog.ShowAsync();






Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s