SciLor's Open Source Forums
http://forum.scilor.com/

Exception on download start
http://forum.scilor.com/viewtopic.php?f=179&t=202
Page 1 of 1

Author:  oruam57 [ Fri May 21, 2010 7:45 pm ]
Post subject:  Exception on download start

First of all thanks for GrooveDownloaderWM!

Unfortunately, I could not download at all because I got an exception anytime I started a download.

So I looked for the cause. I found the problem here

public static void StartUp()
{
AppPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
if (AppPath.StartsWith(@"file:\"))
{
AppPath = AppPath.Substring(6);
}
DownloadDir = Path.Combine(AppPath, "Downloads");
MyProject.Forms.frmGroove.Text = myProgram.longname + " - " + myProgram.version;
MyProject.Forms.frmGroove.Show();
}

in the AppPath initialization. I replaced it with my absolute location

public static void StartUp()
{
AppPath = @"\Storage Card\Program Files\GroovesharkDownloader";
DownloadDir = Path.Combine(AppPath, "Downloads");
MyProject.Forms.frmGroove.Text = myProgram.longname + " - " + myProgram.version;
MyProject.Forms.frmGroove.Show();
}

and now the program works.

Hope it helps for next release.

Author:  SciLor [ Fri May 21, 2010 8:07 pm ]
Post subject:  Re: Exception on download start

Thank you for your support BUT!

The StartUp function doesn't affect the downloads itself directly (It runs and startup).

Code:
AppPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

Just gets the application path

Code:
if (AppPath.StartsWith(@"file:\"))
{
AppPath = AppPath.Substring(6);
}

Gets just done if you run it on Windows itself.

I would like to know where you have copied the "not working" version on you device. Is it in "\Storage Card\Program Files\GroovesharkDownloader"?

Also I would like to know which error the programs throws!

Author:  oruam57 [ Fri May 21, 2010 8:54 pm ]
Post subject:  Re: Exception on download start

SciLor wrote:
The StartUp function doesn't affect the downloads itself directly (It runs and startup).


Yes, I know. The problem is that StartUp initializes AppPath and/or DownloadDir to something wrong that produces an exception when it is used to create the path where store the downloaded files.

By the way, you used Assembly.GetExecutingAssembly().GetName().CodeBase It may be correct but I would have used Assembly.GetCallingAssembly.ManifestModule.FullyQualifiedName

SciLor wrote:
I would like to know where you have copied the "not working" version on you device. Is it in "\Storage Card\Program Files\GroovesharkDownloader"?)


Yes.

SciLor wrote:
I also I would like to know which error the programs throws!


The exception was a ArgumentException and was raised by the Directory.CreateDirectory here

private void btnDownload_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
this.btnAddToDownload.Enabled = false;
this.btnDownload.Enabled = false;
this.DownloadEnabled = true;
this.pgbAllDownloads.Value = 0;
this.pgbAllDownloads.Maximum = this.lstDownloadList.Items.Count;
int num4 = this.lstDownloadList.Items.Count - 1;
for (int i = 0; i <= num4; i++)
{
string path = Path.Combine(MyStartUp.DownloadDir, Path.Combine(Path.Combine(this.DownloadResults[i].ArtistName, this.DownloadResults[i].AlbumName + "(" + this.DownloadResults[i].Year + ")"), this.DownloadResults[i].ArtistName + " - " + this.DownloadResults[i].Name + " - " + this.DownloadResults[i].AlbumName + "(" + this.DownloadResults[i].Year + ").mp3"));
GroovesharkAudioStream musicStream = this.grooveClient.GetMusicStream(this.DownloadResults[i].SongID);
int num2 = 0;
byte[] buffer = new byte[0x400];
if (!Directory.Exists(Path.GetDirectoryName(path)))
{
Directory.CreateDirectory(Path.GetDirectoryName(path));

Author:  SciLor [ Fri May 21, 2010 8:58 pm ]
Post subject:  Re: Exception on download start

Thank you,

the problem is, that I do not check for special characters, that are not allowed in paths when I use them for the directory names/file names.
This problem will be fixed :), I was just to lazy :D.

If you find any more problems, please continue posting them here ;)

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/