Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

(VC#) eingebettete Datei aus Resource speichern

Empfohlene Antworten

Hallo,

ich versuche eine eingebettete Resourcedatei aus der Resource auf die Festplatte zu speichern, aber irgendwie klappt es nicht,

Beispiel ist eine Form mit einem Button der die eindebette Datei Test.pdf als Test1.pdf auf die Platte speichern soll.


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Reflection;

using System.IO;


namespace WindowsFormsApplication3

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }


  public static void WriteResourceToFile(string resourceName, string fileName)

        {

            using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))

            {

                if (s != null)

                {

                    byte[] buffer = new byte[s.Length];

                    char[] sb = new char[s.Length];

                    s.Read(buffer, 0, (int)(s.Length));

                    // convert the byte into ASCII text

                    for (int i = 0; i <= buffer.Length - 1; i++)

                    {

                        sb[i] = (char)buffer[i];

                    }

                    using (StreamWriter sw = new StreamWriter(fileName))

                    {

                        sw.Write(sb);

                        sw.Flush();

                    }

                }

            }

        }


        private void Form1_Load(object sender, EventArgs e)

        {


        }


        private void button1_Click(object sender, EventArgs e)

        {

            WriteResourceToFile("Test.pdf", "Test1.pdf");

        }

    }

}

post-72451-14430449209973_thumb.jpg

Hat jemand eineIdee was ich falsch mache oder hat jemand ein Beispiel dafür?

Danke.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.