C
C#2y ago
wawa

✅ this extractor writes the project name + the file name how do I make it just say the file name

This extractor which I got from stackoverflow because I dont know how to code in c# that much which extracts from embedded resource writes the project name eg if the file was named music.wav and the project name was extract then when it outputs it would rename the extracted file to "extract.music.wav" instead of just "music.wav" How would I make this code keep the original name
using System;
using System.Reflection;
using System.IO;
using System;

namespace program
{
class prog
{
public static void Main(string[] args)
{
var assembly = Assembly.GetExecutingAssembly();

var names = Assembly.GetExecutingAssembly().GetManifestResourceNames();

foreach (string filename in names)
{
var stream = assembly.GetManifestResourceStream(filename);
var rawFile = new byte[stream.Length];

stream.Read(rawFile, 0, (int)stream.Length);

using (var fs = new FileStream(filename, FileMode.Create))
{
fs.Write(rawFile, 0, (int)stream.Length);
}
}
}
}
}
using System;
using System.Reflection;
using System.IO;
using System;

namespace program
{
class prog
{
public static void Main(string[] args)
{
var assembly = Assembly.GetExecutingAssembly();

var names = Assembly.GetExecutingAssembly().GetManifestResourceNames();

foreach (string filename in names)
{
var stream = assembly.GetManifestResourceStream(filename);
var rawFile = new byte[stream.Length];

stream.Read(rawFile, 0, (int)stream.Length);

using (var fs = new FileStream(filename, FileMode.Create))
{
fs.Write(rawFile, 0, (int)stream.Length);
}
}
}
}
}
5 Replies
Pobiega
Pobiega2y ago
strip the assembly name from the fileName variable before creating the file?
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
wawa
wawaOP2y ago
how do i do htat
Pobiega
Pobiega2y ago
close the thread? use /close
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server