Click here to Skip to main content
15,910,603 members
Home / Discussions / C#
   

C#

 
GeneralRe: OdbcCommandBuilder for MySQL Pin
AhsanS13-Mar-08 2:43
AhsanS13-Mar-08 2:43 
GeneralRe: OdbcCommandBuilder for MySQL Pin
adi.rusu13-Mar-08 3:13
adi.rusu13-Mar-08 3:13 
GeneralCurrencymanager Pin
topcatalpha13-Mar-08 1:00
topcatalpha13-Mar-08 1:00 
QuestionGenerate Example from Regex? Pin
BhaaL-san13-Mar-08 0:19
BhaaL-san13-Mar-08 0:19 
AnswerRe: Generate Example from Regex? Pin
leppie13-Mar-08 0:48
leppie13-Mar-08 0:48 
GeneralRe: Generate Example from Regex? Pin
BhaaL-san13-Mar-08 2:00
BhaaL-san13-Mar-08 2:00 
AnswerRe: Generate Example from Regex? Pin
Chetan Patel13-Mar-08 2:27
Chetan Patel13-Mar-08 2:27 
GeneralZip files and send to sever Pin
minniemooo12-Mar-08 23:48
minniemooo12-Mar-08 23:48 
My code below gets files from a list box and Zip those files into one Zip file.
My propble is: This works perfectly when i log on to the server and do this operation on the sever itself.(it is an Intranet).
But when i do this on my local machine which is on the same network as the server, it only creates the Zip file but its empty.
Can someone please help.


//Zip
txtsave.Text = "c:\\TempUpload";

System.IO.Directory.CreateDirectory(txtsave.Text);
if(ListBox1.Items.Count < 1)
{
listerror.Text = "Please add Files to the list Box and Press Confirm";
return;
}

if (txtsave.Text == string.Empty)
{
listerror.Text = "save folder not selected";
return;
}

string[] sTemp = txtsave.Text.Split('\\');
string sZipFileName = sTemp[sTemp.Length - 1].ToString();

FileInfo fi = new FileInfo(txtsave.Text + "\\" + sZipFileName + ".zip");

if(!System.IO.Directory.Exists(txtsave.Text + "\\TempZipFile\\"))
{
System.IO.Directory.CreateDirectory(txtsave.Text + "\\TempZipFile\\" + ".zip");
}

string sTargetFolderPath = (txtsave.Text + "\\TempZipFile\\");

for (int i =0; i< ListBox1.Items.Count;i++)
{
string filepath = ListBox1.Items[i].ToString();
FileInfo fi2 = new FileInfo(filepath);
if(fi2.Exists)
{

try
{
fi2.CopyTo(sTargetFolderPath + fi2.Name, true);
}
catch
{
System.IO.Directory.Delete(sTargetFolderPath);
listerror.Text = "Error on Files";
return;
}
}
}
try
{
string[] filenames = Directory.GetFiles(sTargetFolderPath);
using (ZipOutputStream s = new ZipOutputStream(File.Create(txtsave.Text + "\\" + sZipFileName + ".zip")))
{
s.SetLevel(9);

byte[] buffer = new byte[4096];

foreach (string file in filenames)
{
ZipEntry entry = new ZipEntry(Path.GetFileName(file));

entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);

using (FileStream fs = File.OpenRead(file))
{
int sourceByte;
do
{
sourceByte = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceByte);
} while(sourceByte > 0); }
}
s.Finish();
s.Close();
}
System.IO.Directory.Delete(txtsave.Text + "\\TempZipFile\\", true);

}
catch(Exception ex)
{
listerror.Text = ex.Message.ToString();
}
GeneralRe: Zip files and send to sever Pin
Christian Graus12-Mar-08 23:58
protectorChristian Graus12-Mar-08 23:58 
Generalcompare today's date and last created file than if more than 7 days delete it Pin
blue112-Mar-08 23:44
blue112-Mar-08 23:44 
GeneralRe: compare today's date and last created file than if more than 7 days delete it Pin
Christian Graus13-Mar-08 0:00
protectorChristian Graus13-Mar-08 0:00 
GeneralRe: compare today's date and last created file than if more than 7 days delete it Pin
blue113-Mar-08 0:06
blue113-Mar-08 0:06 
GeneralRe: compare today's date and last created file than if more than 7 days delete it Pin
phannon8613-Mar-08 0:26
professionalphannon8613-Mar-08 0:26 
GeneralRe: compare today's date and last created file than if more than 7 days delete it Pin
Christian Graus13-Mar-08 0:28
protectorChristian Graus13-Mar-08 0:28 
Generalcompare today's date and last created file than if more than 7 days delete it Pin
blue112-Mar-08 23:43
blue112-Mar-08 23:43 
GeneralDebug and Release Mode Pin
half-life12-Mar-08 22:54
half-life12-Mar-08 22:54 
GeneralRe: Debug and Release Mode Pin
Bekjong12-Mar-08 23:36
Bekjong12-Mar-08 23:36 
GeneralRe: Debug and Release Mode Pin
half-life13-Mar-08 6:32
half-life13-Mar-08 6:32 
GeneralRe: Debug and Release Mode Pin
Colin Angus Mackay12-Mar-08 23:37
Colin Angus Mackay12-Mar-08 23:37 
GeneralRe: Debug and Release Mode Pin
half-life13-Mar-08 6:33
half-life13-Mar-08 6:33 
GeneralRe: Debug and Release Mode Pin
DJ van Wyk13-Mar-08 2:36
professionalDJ van Wyk13-Mar-08 2:36 
GeneralSystem.Reflection.MethodInfo [modified] Pin
Waheed Ur Rehman12-Mar-08 21:45
Waheed Ur Rehman12-Mar-08 21:45 
GeneralRe: System.Reflection.MethodInfo Pin
Colin Angus Mackay12-Mar-08 23:35
Colin Angus Mackay12-Mar-08 23:35 
GeneralMode Dialog in Vista Pin
jason_mf12-Mar-08 20:15
jason_mf12-Mar-08 20:15 
GeneralRe: Mode Dialog in Vista Pin
Christian Graus12-Mar-08 20:53
protectorChristian Graus12-Mar-08 20:53 

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.