|
Do you have an Antivirus that prohibits .EXE downloads?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
you're in the wrong forum, but this code is useless, because it will only work if the server is also the machine doing the browsing. No way is IE going to let you run an exe on the local machine. If you want to download an exe, set the content type and use response.binarywrite, then use a path like this to read the file on the file system if you like. In javascript, you'd also redirect to a page that streams the file down.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
LalithaSJ wrote: unable to download .exe files
Can you describe what happens? Do you get an error? What error message are you getting?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
try different approach. Use this code in some button click event handler
FileStream fs = null;
string strContentType = "application/octet-stream";
string strPath = Server.MapPath("FILE_LOCATION_HERE") + "\\";
String strFileName = "FILE_NAME_HERE";
if (File.Exists(strPath + strFileName))
{
byte[] bytBytes = new byte[fs.Length];
fs = File.Open(strPath + strFileName, FileMode.Open);
fs.Read(bytBytes, 0, (int)fs.Length);
fs.Close();
Response.AddHeader("Content-disposition", "attachment; filename=" + strFileName);
Response.ContentType = strContentType;
Response.BinaryWrite(bytBytes);
Response.End();
}
Strahil Shorgov
|
|
|
|
|
Thanks alot Strahil Shorgov!!
|
|
|
|
|
I want to pass text of a combobox in my form to crystal report to use as header title.
How can I do this?
|
|
|
|
|
Hi,
Here is the code snippet:
CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
reportDocument.Load("samplereport.rpt");
reportDocument.SummaryInfo.ReportTitle = comboBox1.Text;
reportDocument.SetDataSource(dset);
crystalReportViewer1.ReportSource = reportDocument;
Thanks,
Gopal.S
|
|
|
|
|
|
I'm writing a C# plugin for a C app, which has well defined API's, structures, etc. I'm trying to figure out how to use a icon / image resource in my C# project and properly convert it to the C struct.
For example, the C struct I have to use is:
struct medium_entry<br />
{<br />
unsigned int struct_size;<br />
<br />
char *medium;<br />
char *description;<br />
int allows_accounts;<br />
int allows_connections;<br />
<br />
ttkCallback callback;<br />
void *data;<br />
<br />
unsigned char *png_image_32;<br />
unsigned int png_image_32_len;<br />
unsigned char *png_image_16;<br />
unsigned int png_image_16_len;<br />
};
Here is the C# representation of that struct, which the P/Invoke Interop Assistant tool (winsiggen.exe) generated for me:
<br />
[StructLayoutAttribute( LayoutKind.Sequential )]<br />
public class medium_entry<br />
{<br />
public uint struct_size;<br />
<br />
[MarshalAsAttribute( UnmanagedType.LPStr )]<br />
public string medium;<br />
<br />
[MarshalAsAttribute( UnmanagedType.LPStr )]<br />
public string description;<br />
<br />
public ttkCallback callback;<br />
<br />
public System.IntPtr data;<br />
<br />
[MarshalAsAttribute( UnmanagedType.LPStr )]<br />
public string png_image_32;<br />
<br />
public uint png_image_32_len;<br />
<br />
[MarshalAsAttribute( UnmanagedType.LPStr )]<br />
public string png_image_16;<br />
<br />
public uint png_image_16_len;<br />
<br />
public medium_entry_t()<br />
{<br />
this.struct_size = (uint)Marshal.SizeOf( typeof( medium_entry ) );<br />
}<br />
}<br />
Here is sample code on how the image would be loaded in C:
<br />
HRSRC ImageRes;<br />
data *medium_entry;
HMODULE hInstance;
<br />
ImageRes = FindResource(hInstance, MakeIntResource(102), "PNG");<br />
data->png_image_32 = LockResource(LoadResource(hInstance, ImageRes));<br />
data->png_image_32_len = SizeOfResource(hInstance, ImageRes);<br />
I've tried two different methods of loading up an image and storing it in the medium_entry class, but neither have worked in the C app, so I assume I'm doing something wrong.
The managed way:
<br />
Bitmap bmp = null;<br />
System.IO.Stream imgStream = thisExe.GetManifestResourceStream( "Plugin.Resources.online_16x16.png" );<br />
<br />
bmp = Bitmap.FromStream( imgStream ) as Bitmap;<br />
if ( !( null == bmp ) )<br />
{<br />
Rectangle rect = new Rectangle( 0, 0, bmp.Width, bmp.Height );<br />
BitmapData bmpData = bmp.LockBits( rect, ImageLockMode.ReadOnly, bmp.PixelFormat );<br />
MediumEntry.png_image_16 = bmpData.Scan0;<br />
MediumEntry.png_image_16_len = (uint)imgStream.Length;<br />
<br />
bmp.UnlockBits( bmpData );<br />
}<br />
The C interop way:
<br />
IntPtr hMod = WinLoadApi.LoadLibraryEx(Pathtoatestdllwithpngimage, IntPtr.Zero, WinLoadApi.LOAD_LIBRARY_AS_DATAFILE);<br />
IntPtr hRes = WinLoadApi.FindResource(hMod, 209, "PNG");<br />
MediumEntry.png_image_16 = WinLoadApi.LoadResource(hMod, hRes);<br />
MediumEntry.png_image_16_len = WinLoadApi.SizeofResource(hMod, hRes);<br />
1) Should png_image_32/16 really be an IntPtr instead of String? I've tried both ways in code (actually the code above mostly uses IntPtr).
2) What am I missing, because I simply can't get ANY sort of image loaded from C# to show up in the C. app using its defined structure.
|
|
|
|
|
I am faced with a task of opening a provided comma delimited file which is in .csv., i.e I wish to open it in a spread sheet program. Any hints on the code format in C# . It has specific headers and will therefore end up with a list of workers having different values under each header. Many thanks.
|
|
|
|
|
If the spreadsheet is Excel, it will open a csv. Either way, how do you mean, to open it in C#, if you're opening it in an external program ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have opened the file using a C# program i have created. i am able to read the contents in a textbox using streamreader inputstream and openfile dialogue. But I wish to be able to read/access the contents in excel using my C# program.
|
|
|
|
|
OK - there's a library you can use to control Excel from C#, the Microsoft tools for office, or something ? Excel will just read yourcsv,but you can create workbooks in C#
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Any other suggestions,contributions? Not there yet.
|
|
|
|
|
Read my article on how to use google ?
http://www.google.com.au/search?sourceid=navclient&ie=UTF-8&rlz=1T4ADBS_enAU225AU226&q=C%23+Excel[^] is bursting with info.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Then you can't possibly want to do what you seem to be saying.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have this comma delimited file sent to me. I can open it in excel straightaway by downloading. But I am trying to understand how I can access it using my C# program codes. I have managed to open it quiet well in a textbox. Now since it already a comma delimited file I am trying to find a way of getting to it through my c# program and reading it as an excel thing using my c# program.
|
|
|
|
|
You wish to load the CSV file into your application with a grid view like in excel?
If so you need to read the CSV data into a dataset and then point that dataset to a data grid view control and it'll display just fine. To make changes and save them you'd need to serialize and convert the dataset back into CSV.
If you want to just open it in excel (if installed) you can just do the following:
string csvFilePath = "C:\myFile.csv";
using (Process MSexcel = new Process())
{
MSexcel.StartInfo.FileName = csvFilePath;
MSexcel.Start();
}
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
I have a data in a list, and l want to print to data form. How can l do this in C#. Thank you .
|
|
|
|
|
Is this an ASP.NET app ? I thought you were asking ASP.NET questions earlier ?
Use a datagrid. And buy a book, this is a very basic question.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for your response.
|
|
|
|
|
MessageBox.Show("Hellow")
it will print the hellow message in the popup messagebox.
or try Sytem.Console.Writeln("hellow");
|
|
|
|
|
Hi,
I am builting a server\client chat aplication.
One problem as appear to me when transfering data between server and client. I m not only trying to transfer messages data but also settings data, like for exemple the list(edit a listbox) of clients logged in!!!
I solved it in a not very elegant way:
1) server sends string data (01hello jack!!!),(04Boris),(09Boris),(02Hello Diana!)
2) client reads it with the help of the substring funtion (01:Private Message),(04:Login),(09:Logout),(02:Global Message)
I use it because i only send strind data?
Here´s my way of solving the problem!!!
Does anyone uses a different way?
|
|
|
|
|
Not me, personally.
String Manipulation (.Substring, .Replace) ftw!
-= Reelix =-
|
|
|
|