How to download files from Google Cloud Storage [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have this working code which read and print out a list of file name from Google Bucket in C#.
GoogleCredential credential = null;
using (var jsonStream = new FileStream(#"D:\data.json", FileMode.Open,
FileAccess.Read, FileShare.Read))
{
credential = GoogleCredential.FromStream(jsonStream);
}
var storageClient = StorageClient.Create(credential);
// List objects
foreach (var obj in storageClient.ListObjects(bucketName, ""))
{
Console.WriteLine(obj.Name);
}
My question is how to I auto download this list of files into my computer?

I managed to solve it by using DownloadObject method from StorageClient object.

Related

How to export CSV to Db with headers in C#? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
How to export csv to db in C#. It works fine when you have a plain text simple text. But in my case I need to parse headers as single row.
There are many options!
use some driver custom functions (depends on your database)
use a [schema.ini](
https://learn.microsoft.com/en-us/sql/odbc/microsoft/schema-ini-file-text-file-driver)
do it manually ...
You can do it manually with while iteration. Before using loop, you should read csv file from path with StreamReader.
For example:
using(var csvReader = new StreamReader(System.IO.File.OpenRead("your file path")))
{
while (!csvReader.EndOfStream)
{
var rows = csvReader.ReadLine();
var columns = rows.Split(';');
if(values.Length > 1)
{
// Your logic getting values to save db
}
}
}

C# How to create a zip file from 3 directory contents [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
pseudo code:
c:\temp\Backup.zip = (c:\Temp\Config*.* , c:\Temp\Data*., c:\Temp\scripts*.)
Thanks in Advance!
Try DotNetZip library. DotNetZip
Here is a very simple example:
ZipFile zipFile = new ZipFile();
zipFile.AddFile("{path}/file.txt");
zipFile.Save("{path}/filename.zip");
zipFile.Dispose();
For doing this with files in a directory you can use
string [] files = Directory.GetFiles("directoryPath", "*.txt");
And add to zipFile instance each file in the array. Notice: Second parameter in Directory.GetFiles function is the search pattern

Streamreader Directory [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm working with StreamReader in my Asp.Net mvc application.
I'm having an issue getting the StreamReader to use the root of my application, and not the C:// drive on my machine.
I have the following:
public ActionResult Test()
{
XmlSerializer serializer = new XmlSerializer(typeof(Test));
TextReader textReader;
textReader = new StreamReader("../Content/items.xml");
Test test = (Test)serializer.Deserialize(textReader);
textReader.Close();
return View(test);
}
When you run a web application, the current working directory of the process isn't the directory containing your source code. You might want to look at HttpServerUtility.MapPath or HostingEnvironment.MapPath.
Note that this doesn't really have anything to do with StreamReader - for diagnostic purposes, you'd be better off with something like:
FileInfo file = new FileInfo("../Content/items.xml");
Debug.WriteLine(file.FullName);

What is IsolatedStorageFileStream? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
In examples on how to use IsolatedStorage I have found two main techniques:
var appStorage = IsolatedStorageFile.GetUserStoreForApplication();
using (var writer = new StreamWriter(appStorage.CreateFile("fileName", FileMode.Create, FileAccess.Write)))
{
writer.WriteLine("Text");
writer.Close()
}
And the other:
var appStorage = IsolatedStorageFile.GetUserStoreForApplication();
using (StreamWriter writer = new StreamWriter(new IsolatedStorageFileStream("fileName", FileMode.Create, FileAccess.Write, appStorage)))
{
writeFile.WriteLine("Text");
writeFile.Close();
}
My question is: Is there any real difference between these two techniques?
As well as: Is either method usually preffered by developers? Or is it just down to personal Opinion?
IsolatedStorageFile is essentially a pointer to the isolated storage file (area) on disk.
IsolatedStorageFileStream is an in-memory representation of the data in a file within the isolated storage area.

What is The Easiest, fastest Way to capture video stream from camera with C#? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
What is The Easiest, fastest Way to capture video stream from camera with C#?
Simpliest and easiest probably would be using Microsoft Expression Encoder SDK:
static void Main( string[] args )
{
var job = new Microsoft.Expression.Encoder.Live.LiveJob();
job.AddDeviceSource( job.VideoDevices[0],job.AudioDevices[0] );
var w = new System.Windows.Forms.Form();
w.Show();
var source = job.DeviceSources[0];
source.PreviewWindow = new Microsoft.Expression.Encoder.Live.PreviewWindow( new System.Runtime.InteropServices.HandleRef(w, w.Handle) );
Console.ReadKey();
}
Take a look at DotImaging project on Github:
https://github.com/dajuric/dot-imaging
var reader = new CameraCapture(); //create camera/file/image-directory capture
reader.Open();
var frame = reader.ReadAs<Bgr<byte>>(); //read single frame
reader.Close();
and more detailed sample:
https://github.com/dajuric/dot-imaging/blob/master/Samples/Capture/Program.cs
NuGet package is available at:
https://www.nuget.org/packages/DotImaging.IO/
It is pretty easy.

Categories