Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7421161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:21:47+00:00 2026-05-29T08:21:47+00:00

So far i wrote a code to download a file from ftp server then

  • 0

So far i wrote a code to download a file from ftp server then using 3rd party dll (media info) to get the metadata details about the file. Until this am good,now am trying to generate the xml file based on my output ,i seen great examples here How can I build XML in C#? to generate xml but my scenario is little bit different,thats why i created this thread.

below is the code to get the properties value of jpg file

 static void Main(string[] args)
 {
     try
     {

         string file = "test.jpg";
         FtpWebRequest reqFTP;
         string ftpserverIp = "1.0.0.1";
         string fileName = @"c:\downloadDir\" + file;
         FileInfo downloadFile = new FileInfo(fileName);
         FileStream outputStream = new FileStream(fileName, FileMode.Append);
         reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpserverIp + "/" + file));
         reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
         reqFTP.UseBinary = true;
         reqFTP.KeepAlive = false;
         reqFTP.Timeout = -1;
         reqFTP.UsePassive = true;
         reqFTP.Credentials = new NetworkCredential("sh", "SE");
         FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
         Stream ftpStream = response.GetResponseStream();
         long cl = response.ContentLength;
         // reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
         int bufferSize = 4096;
         int readCount;
         byte[] buffer = new byte[bufferSize];
         readCount = ftpStream.Read(buffer, 0, bufferSize);
         Console.WriteLine("Connected: Downloading File");
         while (readCount > 0)
         {
             outputStream.Write(buffer, 0, readCount);
             readCount = ftpStream.Read(buffer, 0, bufferSize);
             Console.WriteLine(readCount.ToString());
         }

         ftpStream.Close();
         outputStream.Close();
         response.Close();
         Console.WriteLine("Downloading Complete");
         var message = new StringBuilder();
         ConsoleApplication2.Program TechMeta = new ConsoleApplication2.Program();
         TechMeta.PutMessage(file, message);
         Console.WriteLine(message);
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }


 }

 private void PutMessage(string filename, StringBuilder message)
 {

     //Check the file is video or Image file here
     string extension =".jpg";

     bool b;
     if (b = filename.Contains(extension))
     {

         HowToUse_Dll.ImageInterrogator imageInterrogator = new HowToUse_Dll.ImageInterrogator();
         imageInterrogator.LoadFile(filename);
         message.AppendFormat(messageFormat, "Width", imageInterrogator.GetWidth(), Environment.NewLine);
         message.AppendFormat(messageFormat, "Height", imageInterrogator.GetHeight(), Environment.NewLine);
         message.AppendFormat(messageFormat, "FileSize", imageInterrogator.GetFileSize(), Environment.NewLine);
         message.AppendFormat(messageFormat, "FileFormat", imageInterrogator.GetFileFormat(), Environment.NewLine);
         message.AppendFormat(messageFormat, "Resolution", imageInterrogator.GetResolution(), Environment.NewLine);
     }
     else
     {

          HowToUse_Dll.VideoInterrogator videoInterrogator = new HowToUse_Dll.VideoInterrogator();
          videoInterrogator.LoadFile(filename);
          message.AppendFormat(messageFormat, "FileSize", videoInterrogator.GetFileSize(), Environment.NewLine);
          message.AppendFormat(messageFormat, "Duration", videoInterrogator.GetDuration(), Environment.NewLine);
          message.AppendFormat(messageFormat, "AspectRatio", videoInterrogator.GetAspectRatio(), Environment.NewLine);
          message.AppendFormat(messageFormat, "GetAspectRatio", videoInterrogator.GetAspectRatio(), Environment.NewLine);
          message.AppendFormat(messageFormat, "BitRate", videoInterrogator.GetBitRate(), Environment.NewLine);
          message.AppendFormat(messageFormat, "Format", videoInterrogator.GetFormat(), Environment.NewLine);
          message.AppendFormat(messageFormat, "VideoCoder", videoInterrogator.GetVideoCoder(), Environment.NewLine);
          message.AppendFormat(messageFormat, "Redirector", videoInterrogator.GetRedirector(), Environment.NewLine);
          message.AppendFormat(messageFormat, "TargetPlayback", videoInterrogator.GetTargetPlayback(), Environment.NewLine);
     }

 }

 public string messageFormat
 {
     get
     {
         return "{0}: {1}{2}";
     }
 }

base on the test.jpg file it ,TechMeta.PutMessage(file, message);
Message value are

    {Width: 1024
     Height: 576
     FileSize: 84845
     FileFormat: JPEG
     Resolution: 8
     }

Now am trying to generate xml file based on the value like below,the more importantly am trying to append based on new file like below

<image Name="test.jpg">
<width>1024</width>
<height>576</height>
<file-Size>84845</file-Size>
<resolution>8</resolution>
<image Name="test1.jpg">
<width>1024</width>
<height>576</height>
<file-Size>84845</file-Size>
<resolution>8</resolution>

Any suggestion please

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:21:48+00:00Added an answer on May 29, 2026 at 8:21 am

    You might want to take a look into the class XmlWriter.

    Edit: Wrong Link, fixed now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to download a file from the internet. And so far I have
On behalf, sorry for my far from perfect English. I've recently wrote my self
The code I wrote so far is: void copyInOrder(TNode *orgTree, Tnode *& copyTree){ if(orgTree
So far I have managed to write some code that should print the source
As far as I know, Flash has to pass info off to another external
We're having a problem getting Word documents to download in IE7/IE8 using window.open calls.
I wrote some code to automatically track many objects through an 1000+ frame image
I am trying to download a set of .jpg's from Amazon S3 and store
I wrote a short bit of WatiN code (see below). it works great in
I wrote a code in C# that maps logical drives to their physical disks,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.