|
Hello,
How to read and print *.plt file by C#?
Thank you!
|
|
|
|
|
There are several interesting articles on how to do this here[^]. The assumption is that you are automating AutoCAD from .NET. If you are attempting to do this without AutoCAD, you're going to have to find a component that reads and understands AutoCAD files.
This space for rent
|
|
|
|
|
Overview
I'm working on this class to asynchronously copy files to/from the server. I want to run it in tasks so that I can copy many files at one time without blocking.
I've pieced this class together from Google results and trial and error. It does two things for me:
1) Reports the progress of the copy
2) Reports when it's done.
The FileEx class I got from here[^].
Questions
1) How can I include the name of the file in the progress?
2) How can I include the name of the file when done?
Here's the class:
using System;
using System.Threading.Tasks;
using MyApp.FileTransfer;
using MyApp.Client.Classes;
namespace MyApp.Client.FileTransfer
{
public class LANFileTransfer : IFileTransfer
{
#region Public Methods
public async void DownloadFile(string sourceFile, string destFile)
{
await Task.Run(async () =>
{
await TransferFile(sourceFile, destFile);
}).ContinueWith((t) => FileTransferComplete(t));
}
#endregion
#region Private Methods
private void FileTransferComplete(Task task)
{
}
private void FileTransferProgress(double percentage)
{
}
private async Task TransferFile(string sourceFile, string destFile)
{
IProgress<double> progress = new Progress<double>(FileTransferProgress);
await FileEx.CopyAsync(sourceFile, destFile, progress);
}
#endregion
}
}
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
1st thought ... the CopyFileEx routine has a lpData input that is passed to the callback function(s?) - could you pass a pointer to the string filename here ?
(there's also a nice article on wrapping CreateFileEx here .NET Reference Guide | .NET Book Recommendations | InformIT[^] that you may get some mileage out of - I note Jim calls this pointer 'UserData')
2nd thought .. not sure Im going to use the correct terminology .. 'daisy chain the callbacks' - the first CreateFileEx (or whatever) callback calls an Internal to your class callback-handler - you then from this handler call your 'external' handler from here adding any other information you want
3rd thought - Im certifiable
|
|
|
|
|
Your DownloadFile method looks off to me. Calling Task.Run just to await the result doesn't really achieve anything.
It would be cleaner to use Task.Yield to force the rest of the method to execute in the continuation.
You should also return a Task so that the calling method can wait for the transfers to complete.
Avoid async void methods - You've Been Haacked[^]
To pass the file names to the progress method, you just need to capture them in the progress callback.
public async Task DownloadFile(string sourceFile, string destFile)
{
await Task.Yield();
await TransferFile(sourceFile, destFile);
FileTransferComplete(sourceFile, destFile);
}
private async Task TransferFile(string sourceFile, string destFile)
{
Action<double> reportProgress = percentage => FileTransferProgress(sourceFile, destFile, percentage);
IProgress<double> progress = new Progress<double>(reportProgress);
await FileEx.CopyAsync(sourceFile, destFile, progress);
}
private void FileTransferProgress(string sourceFile, string destFile, double percentage)
{
}
private void FileTransferComplete(string sourceFile, string destFile)
{
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you
If it's not broken, fix it until it is
|
|
|
|
|
As you might surmise, you report progress back with an instance of IProgress. When you created it, you limited it to being a double - why not create a structure that encapsulates the double and the filename, and pass this across instead? Then, when you are reporting the progress back, you would need to report progress using this structure instead of just the double.
This space for rent
|
|
|
|
|
Nice idea. Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Hi can you please help me, with main problem. I am try create own menu for disabled peoples. Here is code:
PictureBox pb = new PictureBox();
int pbCounter = 0;
int pbWidth = 100;
int pbHeight = 100;
void MainFormLoad(object sender, EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(@"otherapp\");
foreach (FileInfo f in dir.GetFiles("*.exe"))
{
pbWidth = pbWidth+10;
pbCounter++;
pb.Location = new Point(pbWidth,pbHeight);
pb.Width = 100; pb.Height = 100;
pb.BackColor = Color.AliceBlue;
pb.Name =Convert.ToString(f);
pb.BackgroundImageLayout = ImageLayout.Stretch;
pb.MouseEnter += new System.EventHandler(PicBox);
}
}
void PicBox(object sender, EventArgs e)
{
}
This create last icon for exe files Screenshots:
[img]http:\\88.86.108.112\1.png[/img]
Files is directory
[img]http:\\88.86.108.112\2.png[/img]
Main probem
[img]http:\\88.86.108.112\3.png[/img]
This i want have.
When i have 5 exe files is directory otherapp\ create 5 icon on "dekstop" with names of exec files. And when i am click on icon on "desktop" executet this software.
Thx
|
|
|
|
|
What is your question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Right click the icon on the desktop.
Click Properties.
Click Shortcut.
Click "Change Icon..."
|
|
|
|
|
I have three pages
page 1 :through a submit button in page 1 ...
I want to be redirected in page2 in new tab and page3 in the same tab.
Is that possible?
Page1 contains :
using (MemoryStream memoryStream = new MemoryStream())
{
document.Save(memoryStream, false);
memoryStream.Position = 0;
Session["BinaryData"] = memoryStream.ToArray();
ScriptManager.RegisterStartupScript(this, this.GetType(), "openPDF", "javascript:window.open('../../Service/Pages/Page2.aspx');", true);
Response.Redirect('../../Service/Pages/Page3.aspx');
}
page2: to be opened in a new tab
protected void Page_Load(object sender, EventArgs e)
{
if (Session["BinaryData"] != null)
{
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "inline; filename=" + filename);
Response.BinaryWrite((byte[])Session["BinaryData"]);
}
then page 3:
will be redirected in the same tab
Thanks in advance
|
|
|
|
|
Start by taking out the javascript: protocol from your script registration:
ScriptManager.RegisterStartupScript(this, this.GetType(), "openPDF", "window.open('../../Service/Pages/Page2.aspx');", true);
That should get rid of the script error.
You'll then see a warning from the popup blocker in your browser, since your script is trying to open a new window, and it's not in direct response to the user clicking something on the page.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The Javascript opened the page2 if i commented the line of the
response.redirect to page3
but If I left it like that..
It goes to the page3 (response.redirect)
without opening page2 in the new tab (the register Javascript line)
|
|
|
|
|
Yes, a Response.Redirect will throw away all of the page content, and instead tell the browser to load a different page.
You'll need to remove the server-side redirection, and send back some script to redirect the page on the client:
ScriptManager.RegisterStartupScript(this, this.GetType(), "openPDF", "window.open('../../Service/Pages/Page2.aspx');", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "location.assign('../../Service/Pages/Page3.aspx');", true);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This is working great in chrome ..
but in IE it is always blocked and I need to disable the Pop up blocker.
is any work around to avoid that in IE ?,
And Really Thanks and appreciate your help
|
|
|
|
|
No, there's no way to circumvent the popup blocker. If there was, it wouldn't be much use!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Damn, I just realised why my web dev looks at me funny when I ask him to use dialogs, in Silverlight they are just like a desktop dialog but I guess they are a popup window in ASP/MVC.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks alot ..
but the issue is
when the submit button is gone.. it is gone.. even the user allowed the pop up
the first page is redirected to page3 but the page2 is never opened in a new a tab.
and Page2 is actually a pdf document to be downloaded.. so I could never be able to download it .. in IE
Unless the popup block is not blocking me..
|
|
|
|
|
Hey all,
If I'm on MachineA and remote into MachineB using Terminal Services (remote desktop / mstsc.exe), is it possible for a process that's then launched on MachineB to tell that the user is actually connected from MachineA?
I suspect it's possible, as Task Manager's Users tab can show User/ID/Status/Client Name/Session. What I'm after is Client Name.
|
|
|
|
|
|
Try this[^]. Not sure if it works and not able to give it a try atm, but a bit Googling pointed in that direction.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
This jumps through a lot of hoops to determine the name of the machine the code is running on. What I'm after is the name of the machine the user is remoting from.
Local/remote in this context gets confusing. I'm on OfficePC. I use Remote Desktop to log into ServerMilesAway. I run my app. My app knows (Environment.MachineName) it's running from ServerMilesAway, and I can log that and whatever. But I want my log to also show that the user who launched my app is actually back on OfficePC (not the user's name, which I can already get, but the machine name that started the remote session).
Task Manager can do that. I'd like to be able to do the same.
|
|
|
|
|
Holy crap.
ECHO %CLIENTNAME%
This variable only seems to exist from within RDP sessions.
That'll do.
[Edit] This is the case on Windows 7, but it's still not there on Windows 10. WTF?
[Edit #2] If anyone cares:
Don't know why Microsoft took it out. But the session ID (an int) can be obtained from GetCurrentProcess().SessionId. Once I have this ID, I can go to HKEY_CURRENT_USER\Volatile Environment[SessionID]\CLIENTNAME. That seems to work consistently.
I'm not a huge fan of this solution, but it works so far...
modified 17-Feb-16 16:58pm.
|
|
|
|
|
I want to change the gliphicon button when pressed to show password and then after pressing it again get it back again?
|
|
|
|