M
Matt Theule
I need to be able to allow users to drag files to a list box on a web
page. To this end, I created a Windows Control and hosted it in a
WebForm. When the file is dropped onto the listbox, the path of the
file is truncated down to 8.3 format (with the ~1 at the end). When the
Windows control is hosted in a windows form (for testing purposes) the
full path is displayed.
Is there some setting that will allow the full path to be displayed when
hosted in a WebForm?
Alternatively, is there a different way to achieve the desired
functionality without using a WinForm control?
And less importantly, when hosted in an WebForm, the control is only
able to accept 1 file at a time. When hosted in a WinForm, the control
can accept multiple files. Any ideas?
Thanks
private void listBox1_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
private void listBox1_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
try
{
string[] files = null;
if (e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop))
{
files = (string[])e.Data.GetData("FileDrop", true);
}
foreach (string s in files)
{
listBox1.Items.Add(s);
}
}
catch (Exception exp)
{
System.Windows.Forms.MessageBox.Show(exp.Message);
}
}
page. To this end, I created a Windows Control and hosted it in a
WebForm. When the file is dropped onto the listbox, the path of the
file is truncated down to 8.3 format (with the ~1 at the end). When the
Windows control is hosted in a windows form (for testing purposes) the
full path is displayed.
Is there some setting that will allow the full path to be displayed when
hosted in a WebForm?
Alternatively, is there a different way to achieve the desired
functionality without using a WinForm control?
And less importantly, when hosted in an WebForm, the control is only
able to accept 1 file at a time. When hosted in a WinForm, the control
can accept multiple files. Any ideas?
Thanks
private void listBox1_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
private void listBox1_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
try
{
string[] files = null;
if (e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop))
{
files = (string[])e.Data.GetData("FileDrop", true);
}
foreach (string s in files)
{
listBox1.Items.Add(s);
}
}
catch (Exception exp)
{
System.Windows.Forms.MessageBox.Show(exp.Message);
}
}