Extracting .zip files into memory at runtime (.NET) [closed] - vb.net

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Is there a way to extract a zip file into the computer's memory at runtime (e.g. to extract a picture but put it temporarily in the memory and place it on a PictureBox)
LIBRARIES ARE ALLOWED.

I think this should work.(not tested)
Requires .net 4.5(System.IO.Compression.dll)
using System.IO.Compression;
...
byte [] pictureBuffer = null;
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (var entry in archive.Entries)
{
if(entry.FullName == "SomePicture")
{
using (zipEntryStream = entry.Open())
using (MemoryStream memStream = new MemoryStream())
{
zipEntryStream.CopyTo(memStream);
pictureBuffer = zipEntryStream.ToArray;
}
}
}
I think this should work.(not tested)
using the DotNetZip Library http://www.nuget.org/packages/DotNetZip/
using (ZipFile zip = new ZipFile(zipPath))
{
foreach (var entry in zip.Entries)
{
if(entry.FileName == "SomePicture")
{
using (var zipEntryStream = entry.OpenReader())
using (var memStream = new MemoryStream())
{
zipEntryStream.CopyTo(memStream);
pictureBuffer = zipEntryStream.ToArray;
}
}
}
}

Related

Problem with sending mail with attachment via Admin API [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 17 days ago.
This post was edited and submitted for review 13 days ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
We send emails via the Admin API, with PDF attachments the PDF is then unreadable, with TXT files there is no problem.
Doku: https://shopware.stoplight.io/docs/admin-api/743f0819350c4-send-a-mail
Request-URL: _action/mail-template/send
We use the binAttachments parameter set as follows.
The "content" is fetched and without BASE64 encoding the JSON code is corrupt, if you encode it the mail can be sent. But the attachment is not valid with/without encoding.
$content = file_get_contents()
$binAttachments[] = ["content" => base64_encode($content),
"fileName" => 'test.pdf',
"mimeType" => 'application/pdf'
];
No decode is done in the API controller, here is my suggestion for change?
Adjustment of the controller
\Shopware\Core\Content\MailTemplate\Api\MailActionController
public function send(RequestDataBag $post, Context $context): JsonResponse
direkt nach der Zeile
$data = $post->all();
/optionale Decodierung des Strings, falls es ein BASE64 ist/
foreach ($data['binAttachments'] as &$binAttachment) {
if (base64_decode($binAttachment['content'], true)) {
// is valid $binAttachment['content'] = base64_decode($binAttachment['content']);
} else {
// not valid, Nothing to do
}
}
In addition, an issue has already been created:
https://issues.shopware.com/issues/NEXT-25189
Description see above

Can anybody tell the code to import only selected data(rows and columns) from Excel to SQL through asp.net? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Like here if I want to import from row 5 and column C
protected void Button1_Click(object sender, EventArgs e)
{
String csvPath = Path.Combine( Server.MapPath("~/Files/") +
Path.GetFileName(FileUpload1.PostedFile.FileName));
FileUpload1.SaveAs(csvPath);
DataTable dt = new DataTable();
dt.Columns.AddRange(
new DataColumn[3]{
new DataColumn("KPI", typeof(string)),
new DataColumn("KPIPN", typeof(string)),
new DataColumn("KPIPV", typeof(string))
});
string csvData = File.ReadAllText(csvPath);
You can use the LinqToExcel project
https://github.com/paulyoder/LinqToExcel

Plagiarism Checker C# based API [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am looking for a plagiarism checker API that is based on C# code. I need to use it on my web service. I need to easily query plagiarism checking engine and get result for the originality of the text.
If you know any service that is similar to what I am asking it would be great!
I’m using an online plagiarism checker service called Copyleaks which offers an interface to integrate with their API (HTTP REST). It also provides interface which is fully compatible with C#.
Steps to integrate with Copyleaks API:
Register on Copyleaks website.
Create a new C# Console application project and install Copyleaks’ Nuget Package.
Use the following code which performs a webpage scan.
This code was taken from its SDK (GitHub):
public void Scan(string username, string apiKey, string url)
{
// Login to Copyleaks server.
Console.Write("User login... ");
LoginToken token = UsersAuthentication.Login(username, apiKey);
Console.WriteLine("\t\t\tSuccess!");
// Create a new process on server.
Console.Write("Submiting new request... ");
Detector detector = new Detector(token);
ScannerProcess process = detector.CreateProcess(url);
Console.WriteLine("\tSuccess!");
// Waiting to process to be finished.
Console.Write("Waiting for completion... ");
while (!process.IsCompleted())
Thread.Sleep(1000);
Console.WriteLine("\tSuccess!");
// Getting results.
Console.Write("Getting results... ");
var results = process.GetResults();
if (results.Length == 0)
{
Console.WriteLine("\tNo results.");
}
else
{
for (int i = 0; i < results.Length; ++i)
{
Console.WriteLine();
Console.WriteLine("Result {0}:", i + 1);
Console.WriteLine("Domain: {0}", results[i].Domain);
Console.WriteLine("Url: {0}", results[i].URL);
Console.WriteLine("Precents: {0}", results[i].Precents);
Console.WriteLine("CopiedWords: {0}", results[i].NumberOfCopiedWords);
}
}
}
Call the function with your Username, API-Key and the URL of the content you wish to scan for plagiarism.
You can read more about its server in "How To" tutorial.

Hydbrid App In IBM Worklight [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I Already done updating the password in database using SQLAdpaters in IBM Worklight Hybrid App.
I am Working on Hybrid App using IBM Worklight. I am updating user password in database using SQLAdapter, but I want to store password in encrypted format. I already have the encryption and decryption logic in java class. How can I integrate that java class with my hybrid app?
var procedure1Statement = WL.Server.createSQLStatement("UPDATE USERS SET USERPASSWORD=? WHERE USERNAME = ? AND USERPASSWORD=? ");
function updateUserPassword(newPassword,userName,password) {
return WL.Server.invokeSQLStatement({
preparedStatement : procedure1Statement,
parameters : [newPassword,userName,password]
});
}
changed code as follows
var userpwdUpdateStatement = WL.Server.createSQLStatement("UPDATE USERS SET USERPASSWORD=? WHERE USERNAME = ? AND USERPASSWORD=? ");
function updateUserPassword(newPassword,userName,password) {
var encryptdecryptutility = new com.abcd.bgf.SysCRAESencrpDecrp();
var encryptnewPassword = encryptdecryptutility.encrypt(newPassword);
var encryptoldPassword = encryptdecryptutility.encrypt(password);
return WL.Server.invokeSQLStatement({
preparedStatement : userpwdUpdateStatement,
parameters : [encryptnewPassword,userName,encryptoldPassword]
});
}

7" GPS with wince 6 cf 3.5 can't open com port [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i am using vb 2008 and the serialport object from the system.IO.Ports.SerialPort to connect to com2 serial port on my device to read data from the gps.But when i try to open the port windows troughs an IO Exception. My first thinking was that some other program is using the port but do be sure i tried to open the port with pocket-putty (COM2:) including the colon and all functions and the gps data is flowing. In the documentation of the device the manufacturer writes this:
Pls note for GPS virtual serial port using, Data read not rely on the ComState. CbInQue, read serial data need to specify the length. To test the normal In the Sygic, Igo8, Careland map, detailed methods please use reference in CommTest ReadPortThread.
I don't understand what exactly he means.
My code functions on another Wince device but with wince 5.0 and CF 2.0
i am thankful for every answer
Your port name is wrong. Windows CE requires port names to be suffixed with a colon. The exception message probably told you that the requested port name was not found.
Change the code to this:
mySerialPort.PortName = "COM2:"
Some device do not offer SerialPort access to GPS but a streamed access. Try to open the GPS port as file:
You may need this interop: http://code.google.com/p/win-mobile-code/source/browse/trunk/gps8/Gps8/GPS_Sample8/ReadFile.cs?r=89
and then try opening as file:
#region CN50raw
bgThread2 myStreamReaderThread;
private void OpenStream()
{
//background thread already running?
if (myStreamReaderThread == null)
{
string szPort="";
szPort = GetGPSPort();
if (szPort != "")
{
AddRawText("Start reading stream at '" + szPort +"'");
//start a new thread
myStreamReaderThread = new bgThread2(szPort);
myStreamReaderThread.bgThread2Event += new bgThread2.bgThread2EventHandler(myStreamReaderThread_bgThread2Event);
}
else
AddRawText("No raw GPS port found");
}
}
private void OpenStream(string szPort)
{
//background thread already running?
if (myStreamReaderThread == null)
{
if (szPort != "")
{
AddRawText("Start reading stream at '" + szPort + "'");
//start a new thread
myStreamReaderThread = new bgThread2(szPort);
myStreamReaderThread.bgThread2Event += new bgThread2.bgThread2EventHandler(myStreamReaderThread_bgThread2Event);
}
else
AddRawText("No raw GPS port found");
}
}
void myStreamReaderThread_bgThread2Event(object sender, bgThread2.BgThreadEventArgs bte)
{
AddRawText(bte.sString);
}
private void CloseStream()
{
if (myStreamReaderThread != null)
{
myStreamReaderThread.Dispose();
Application.DoEvents();
myStreamReaderThread = null;
}
Application.DoEvents();
mnuRAWStart.Enabled = true;
mnuRAWStop.Enabled = false;
}
#endregion
the getGpsPort function above uses MS GPSID registry setting to find the raw port name. If your devcice does support GPSID, you do not need all the above and can use GPSID API to get location data of GPS.
Check your device's registry:
private string GetGPSPort()
{
string szStr="";
if (Registry.GetStringValue(Registry.HKLM,
"System\\CurrentControlSet\\GPS Intermediate Driver\\Multiplexer",
"DriverInterface",
ref szStr)
== 0)
{
return szStr;
}
else
{
if (Registry.GetStringValue(Registry.HKLM,
"System\\CurrentControlSet\\GPS Intermediate Driver\\Drivers",
"CurrentDriver",
ref szStr) == 0)
{
string szPath = "System\\CurrentControlSet\\GPS Intermediate Driver\\Drivers\\" + szStr;
if (Registry.GetStringValue(Registry.HKLM, szPath, "CommPort", ref szStr) == 0)
{
return szStr;
}
}
}
return "";
}
The above code lines are sources of my GpsSample application for Windows Mobile (Compact Framework)
Article: http://www.hjgode.de/wp/2010/06/11/enhanced-gps-sample-update/
Code http://code.google.com/p/win-mobile-code/source/browse/trunk/gps8/Gps8/GPS_Sample8/?r=89