Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
2.67/5 (3 votes)
See more:
hi.
I am working in media player I want when I drop a song into my media play it Automatically .
and another problem is when I open with a song with my media player I show a message box
"Illegal characters in path. mscorlib"
what this mean and how can I solve those 2 problems.
Thank.
Posted
Updated 10-Apr-11 23:52pm
v2
Comments
CodingLover 11-Apr-11 4:15am    
How did you embedded player in to your application? Is that a web application or a desktop application?
hamzah1 11-Apr-11 4:19am    
desktop application and yes i embedded it to my widows
CodingLover 11-Apr-11 4:28am    
you can catch the drag-drop event into your form, and pick the file path from it. then load that file in the same way you are playing it by selecting the file.

1 solution

Without seeing the code, it is difficult if not impossible to diagnose the second problem: please provide a relevant code fragment!

For drag and drop:
1) Set the AllowDrop property of your form to True
2) Create a handler for both the DragEnter and DragDrop events of your form.
3) In the DragEnter handler, add the following line of code:
e.Effect = DragDropEffects.Move;

4) In the DragDrop handler, add the following:
string[] files = (string[]) e.Data.GetData(DataFormats.FileDrop);
if (files != null)
    {
    foreach (string file in files)
        {
        Console.WriteLine(file); // Or whatever you need to do...
        }
    }
Or, if you need in in VB...:O
Dim files As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop), String())
If files IsNot Nothing Then
	For Each file As String In files
		Console.WriteLine(file) ' Or whatever you need to do...
	Next
End If
 
Share this answer
 
v2
Comments
hamzah1 11-Apr-11 6:38am    
it give me ana error in this decleartion
string[] files=(string[])
OriginalGriff 11-Apr-11 6:44am    
What error?
hamzah1 11-Apr-11 6:45am    
String class type connot be used as an expression
OriginalGriff 11-Apr-11 7:05am    
Oops! C#, not VB! Answer updated...:blush:
hamzah1 11-Apr-11 7:29am    
Thxxx man it's worked.
can you help me in second problem which is open with ??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900