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 8670533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:43:44+00:00 2026-06-12T18:43:44+00:00

I am creating a file using XmlWriter, XmlWriter writer = XmlWriter.Create(fileName); it is creating

  • 0

I am creating a file using XmlWriter, XmlWriter writer = XmlWriter.Create(fileName); it is creating a file and then i have one more function which i am calling private void EncryptFile(string inputFile, string outputFile) which takes 2 string input and outpulfile and in the end i have two files one is encrypted and one is not. I just want one encrypted file but foor my encrypt function it takes inputfile which is created by XmlWriter. Is there any way i can create memorystream and pass that into my function instead of creating a inputfile.
my encrypt function

private void EncryptFile (string inputFile, string outputFile)
            string password = @"fdds"; // Your Key Here
            UnicodeEncoding UE = new UnicodeEncoding();

            byte[] key = UE.GetBytes(password);
            string cryptFile = outputFile;
            FileStream fsCrypt = new FileStream(cryptFile, FileMode.Create);

            RijndaelManaged RMCrypto = new RijndaelManaged();


            CryptoStream cs = new CryptoStream(fsCrypt,RMCrypto.CreateEncryptor(key,key),CryptoStreamMode.Write);

            FileStream fsIn = new FileStream(inputFile, FileMode.Open);

            int data;
            while ((data = fsIn.ReadByte()) != -1)
                cs.WriteByte((byte)data);
            cs.FlushFinalBlock();
            fsIn.Close();
            cs.Close();
            fsCrypt.Close();
        }
    }      
  • 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-06-12T18:43:45+00:00Added an answer on June 12, 2026 at 6:43 pm

    You can create an XmlWriter that writes to a memory stream:

    var stream = new MemoryStream();
    var writer = XmlWriter.Create(stream);
    

    Now you can pass this stream to your EncryptFile function instead of an inputFile. You have to make sure that you don’t forget these two things before reading the stream:

    1. Make a call to writer.Flush() when you are done writing.
    2. Set stream.Position back to 0 before you start reading the stream.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating excel file using below code public class ResultSetToExcel { private HSSFWorkbook
I'm creating an XML file using Perl and XML::Simple module. I successfully create the
I am creating Excel file download using NOPI libraries. I have lot of data
I have found that creating a zip file using the Zip task provided by
I am creating an XML file using the System.Xml.Serialization module. I have a class
How do one create PDF in memorystream instead of physical file using itextsharp. The
I'm creating some big JSON file using GSON to create custom JSON from GTFS
I trying to create a bat file using csharp which contains some commands. So
Am creating an xml file using xmlwriter,i thought it works fine but when i
I am creating a file using open function and using O_CREAT | O_EXCEL .

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.