mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-06 04:00:07 +00:00
Updated DownloadHandler stuff.
This commit is contained in:
@@ -1,34 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace CefSharp.Example
|
||||
{
|
||||
class DownloadHandler : IDownloadHandler
|
||||
internal class DownloadHandler : IDownloadHandler
|
||||
{
|
||||
private readonly string _path;
|
||||
private Stream _stream;
|
||||
|
||||
public DownloadHandler(string fileName)
|
||||
public bool OnBeforeDownload(string suggestedName, out string downloadPath, out bool showDialog)
|
||||
{
|
||||
_path = Path.Combine(Path.GetTempPath(), fileName);
|
||||
_stream = File.Create(_path);
|
||||
downloadPath = Path.GetTempPath();
|
||||
showDialog = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ReceivedData(byte[] data)
|
||||
{
|
||||
_stream.Write(data, 0, data.GetLength(0));
|
||||
return true;
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Complete()
|
||||
{
|
||||
_stream.Dispose();
|
||||
_stream = null;
|
||||
|
||||
Console.WriteLine("Downloaded: {0}", _path);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,13 @@
|
||||
|
||||
#include "Stdafx.h"
|
||||
|
||||
using namespace System::Runtime::InteropServices;
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
public interface class IDownloadHandler
|
||||
{
|
||||
bool OnBeforeDownload(String^ suggestedName, [Out] String^% downloadPath, [Out] bool% showDialog);
|
||||
bool ReceivedData(array<Byte>^ data);
|
||||
void Complete();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user