Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
QuestionConvert an obsolete old REST documentation Pin
Member 1096750730-Oct-17 0:54
Member 1096750730-Oct-17 0:54 
QuestionHow calculate Checksum for barcode code128 auto? Pin
Le@rner29-Oct-17 20:01
Le@rner29-Oct-17 20:01 
AnswerRe: How calculate Checksum for barcode code128 auto? Pin
Richard MacCutchan29-Oct-17 22:27
mveRichard MacCutchan29-Oct-17 22:27 
AnswerRe: How calculate Checksum for barcode code128 auto? Pin
Sascha Lefèvre29-Oct-17 22:27
professionalSascha Lefèvre29-Oct-17 22:27 
QuestionNo overload for method, error in c# file for Unity. Pin
Member 1349123628-Oct-17 14:33
Member 1349123628-Oct-17 14:33 
AnswerRe: No overload for method, error in c# file for Unity. Pin
Sascha Lefèvre28-Oct-17 14:47
professionalSascha Lefèvre28-Oct-17 14:47 
PraiseRe: No overload for method, error in c# file for Unity. Pin
Member 1349123628-Oct-17 15:25
Member 1349123628-Oct-17 15:25 
QuestionC# Problem extracting file from .zip created with DotNetZip Pin
manic_drummer28-Oct-17 11:58
manic_drummer28-Oct-17 11:58 
I'm writing a C# WinForms project that uses DotNetZip. Here's the step-by-step to save a file:

1. Write the file to a temp file using FileStream and BinaryWriter...

C#
glbstrSaveFilePath = strfilepath;
            string strTempPath = Path.GetTempFileName();
            Path.ChangeExtension(strTempPath, ".bin");

            FileStream fs = new FileStream(strTempPath, FileMode.Create, FileAccess.Write);
            BinaryWriter bw = new BinaryWriter(fs);

            bw.Write(somestring);
            bw.Write(someboolean);
            bw.Write(someotherstring);


2. Next, I use DotNetZip to compress it and save it to the location from the SaveFileDialog...

C#
using (ZipFile zip = new ZipFile())
                {
                    Path.ChangeExtension(strTempPath, ".bin");
                    zip.AddFile(strTempPath, "MyProject");
                    zip.Save(strfilepath);
                }


The file seems to be compressing and saving correctly because I can open the resulting file in 7-Zip and then read the "MyProject" file. Everything looks OK.

Here's where the problem occurs. To open the file I do...

1. Extract the file from its location using DotNetZip...

C#
ZipFile zip = ZipFile.Read(strfilepath);
            Directory.CreateDirectory(strTempPath);
            Path.ChangeExtension(strTempPath, ".bin");
            foreach (ZipEntry e in zip)
            {
                if (e.FileName == "MyProject")
                    e.Extract(strTempPath, ExtractExistingFileAction.OverwriteSilently);
            }


2. Next, I open the temp file (strTempPath) using FileStream and BinaryReader...

C#
FileStream fs = new FileStream(strTempPath, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);

            strStringOne = br.ReadString();
            blBooleanOne = br.ReadBoolean();
            strStringTwo = br.ReadString();



Unfortunately, steps 1 and 2 above don't seem to execute. I'm at a loss to find out why. Is there anything wrong with the code in Step 1?
AnswerRe: C# Problem extracting file from .zip created with DotNetZip Pin
Sascha Lefèvre28-Oct-17 13:35
professionalSascha Lefèvre28-Oct-17 13:35 
AnswerRe: C# Problem extracting file from .zip created with DotNetZip Pin
Bernhard Hiller30-Oct-17 4:18
Bernhard Hiller30-Oct-17 4:18 
Questionc#Move music files in listbox up or down Pin
Member 1348924427-Oct-17 5:00
Member 1348924427-Oct-17 5:00 
AnswerRe: c#Move music files in listbox up or down Pin
Richard MacCutchan27-Oct-17 5:11
mveRichard MacCutchan27-Oct-17 5:11 
GeneralRe: c#Move music files in listbox up or down Pin
Member 1348924427-Oct-17 5:18
Member 1348924427-Oct-17 5:18 
GeneralRe: c#Move music files in listbox up or down Pin
Richard MacCutchan27-Oct-17 5:51
mveRichard MacCutchan27-Oct-17 5:51 
GeneralRe: c#Move music files in listbox up or down Pin
Member 1348924427-Oct-17 6:18
Member 1348924427-Oct-17 6:18 
GeneralRe: c#Move music files in listbox up or down Pin
Richard MacCutchan27-Oct-17 6:42
mveRichard MacCutchan27-Oct-17 6:42 
SuggestionRe: c#Move music files in listbox up or down Pin
Ralf Meier28-Oct-17 12:20
mveRalf Meier28-Oct-17 12:20 
GeneralRe: c#Move music files in listbox up or down Pin
Richard MacCutchan28-Oct-17 22:08
mveRichard MacCutchan28-Oct-17 22:08 
AnswerRe: c#Move music files in listbox up or down Pin
jschell27-Oct-17 7:39
jschell27-Oct-17 7:39 
AnswerRe: c#Move music files in listbox up or down Pin
Gerry Schmitz28-Oct-17 3:31
mveGerry Schmitz28-Oct-17 3:31 
Questionc# Need to be able to play music files that were additional items to the list box Pin
Member 1348924427-Oct-17 3:52
Member 1348924427-Oct-17 3:52 
AnswerRe: c# Need to be able to play music files that were additional items to the list box Pin
OriginalGriff27-Oct-17 3:57
mveOriginalGriff27-Oct-17 3:57 
AnswerRe: c# Need to be able to play music files that were additional items to the list box Pin
Richard Deeming27-Oct-17 4:04
mveRichard Deeming27-Oct-17 4:04 
GeneralSOLVEDRe: c# Need to be able to play music files that were additional items to the list box Pin
Member 1348924427-Oct-17 4:18
Member 1348924427-Oct-17 4:18 
AnswerRe: c# Need to be able to play music files that were additional items to the list box Pin
Gerry Schmitz27-Oct-17 4:26
mveGerry Schmitz27-Oct-17 4:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.