建议正确的工具来执行上下文菜单项或使用.net [英] Advise on proper tools to execute a context menu item or use .net

查看:101
本文介绍了建议正确的工具来执行上下文菜单项或使用.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发Visual Studio 2012中的项目,该项目需要将现有文件从一个文件夹以压缩格式发送到我的Dropbox公用文件夹,获取Dropbox公共链接并通过电子邮件将该链接发送给用户列表。我在获取Dropbox公共链接时遇到问题



我写了一个C Sharp控制台应用程序,它执行以下操作



1)发出OpenFileDialog并选择fullpathname



2)构建一个windows命令字符串来压缩fullpathname并将其放在我的Dropbox公共文件夹中/>


3)检索Dropbox复制公共链接这是Dropbpx上下文菜单中的一个选项



4 )构建和发送电子邮件,并在文本中包含Dropbox Public Link。电子邮件是用SMTP发送的





我能完成第1,2和4项但我无法完成第3项。我不知道我可以用什么或什么可调用工具从DropBox上下文菜单中获取公共链接,或者是否有任何.net命令可以用来获取信息。



欢迎所有建议。我是Windows编程的新手,因为我作为大型机开发人员已经工作了30多年。





谢谢

I am currently working on a project in Visual Studio 2012 that needs to send an existing file from one folder to my Dropbox public folder in zipped format, get the Dropbox public link and email the link to a list of users. I am having a problem getting the Dropbox Public Link

I have written a C Sharp Console Application which does the following

1) issue the OpenFileDialog and select the fullpathname

2) build a windows command string to zip the fullpathname and place it in my Dropbox public folder

3) retrieve the Dropbox "Copy Public Link" this is an option in the Dropbpx Context menu

4) build and email and include the Dropbox Public Link in the text. The email is sent with SMTP


I am able to accomplish items 1, 2 and 4 but am unable to do number 3. I do not know how or what callable tool I can use to get the "Public Link" from the DropBox Context menu or if there are any .net commands which I can use to get the information.

all suggestions are welcome. I am new to windows programming as I have been working as a mainframe developer for over 30 years.


thanks

推荐答案

正如我所见,您试图围绕一些现有的命令行工具和IE包装应用程序。我建议你寻找并使用专用的.net库来完成这些任务。

像这些:

1)ZIP:http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx [ ^ ]

2)DropBox:http://dkdevelopment.net/what-im-doing/dropnet/ [ ^ ]
As I see, you tried to wrap an application around some existing command line tools and IE. I suggest you look for and use dedicated .net libraries for those tasks.
Like these ones:
1) ZIP: http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx[^]
2) DropBox: http://dkdevelopment.net/what-im-doing/dropnet/[^]


我可以通过您对我的问题评论的回复看到你有已经找到了在你自己的DropBox上访问文件的基本方面。



是的,机器上公共文件夹中的DropBox文件使用硬编码的六位数ID号码;但是,共享文件(在共享文件夹中)将具有动态分配的ID号。



这里是从一个小的Windows Forms测试项目中提取的一些工作代码我做了:注意,在这个项目中,这是对DeskTop上的DropBox文件夹进行了硬编码。



由于DropBox没有提供任何公共链接 到公共文件夹内的一个文件夹,这个文件夹名称的程序显示前面是你想要在文件的公共链接上看到的id的类型:有点误导:但是,我想要为了验证目的,我正在开发这个小小的测试平台,这就是单独的文件夹,这就是为什么只有''解析文件夹'选项。
I can see, by your response to my comment on your question, that you have already figured out the essential aspect of accessing files in your own DropBox, on your own computer.

Yes, DropBox files in the Public folder, on your machine, use a hard-coded six-digit ID number; however, shared files (in a shared folder) will have a dynamically assigned ID number.

Here''s some working code pulled from a small Windows Forms test-project I did: note, that, in this project, this is hard-coded for the DropBox folder being on the DeskTop.

Since DropBox does not provide any "public link" to a folder inside the Public folder, the display by this program of folder names preceded by the kind of id you''d want to see on a Public link to a file: is kind of mis-leading: but, I wanted to see the folders separately, as I was developing this little test-bed, for verification purposes, and that''s why a ''parse folders only'' option is there.
// Windows Forms project, single form
// compiled against FrameWork 3.5

// interface elements on Form1:

    // a large TextBox set MultiLine = true
    // to display the results of parsing the DropBox folder
    // tbDropBoxPublicParseResults
    
    // a second smaller TextBox set MultiLine = false
    // to display the "stub" for a valid DropBox link
    // tbDropBoxPublicFolderPath

    // a button, and a Click EventHandler
    // to trigger parsing
    // btnParseDropBoxPublicFolder_Click
    
    // three radiobuttons that determine what to parse
    // rbParseRecursive
    // rbParseTopLevelFiles
    // rbParseTopLevelDirectories

using System;
using System.Text;

// you could omit the 'using statement
// for System.Drawing here, but you must
// have a reference to it for this project
// to compile/run: so I think better to
// leave it in !
using System.Drawing;

using System.Windows.Forms;
using System.IO;

namespace Get_DropBox_Public_Links
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        // here, I've put "123456," for a six-digit
        // DropBox unique ID: of course that's only
        // a placeholder for your own unique ID ...
        private string DBoxPublicLinkHeader = @"https://dl.dropbox.com/u/123456/";

        private string replaceSpaceStr = @"%20";
        private string oneSpace = @" ";
        private string newLine = Environment.NewLine;

        private string DTopFolderPath;
        private string DBoxFolderPath;
        private string[] DBoxFolderFiles;
        private string[] DBoxFolderDirectories;
        //
        private string rawLinkPath;
        private string[] whatToParse;
        //
        private int startOfRawLink;

        private void Form1_Load(object sender, EventArgs e)
        {
            // Note the assumption here: the DropBox folder is on the DeskTop
            DTopFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            DBoxFolderPath = DTopFolderPath + @"\DropBox\Public";
            DBoxFolderFiles = Directory.GetFiles(DBoxFolderPath);
            DBoxFolderDirectories = Directory.GetDirectories(DBoxFolderPath);
            //
            startOfRawLink = DBoxFolderPath.Length + 1;
        }

        private void btnParseDropBoxPublicFolder_Click(object sender, EventArgs e)
        {
            tbDropBoxPublicFolderPath.Text = DBoxPublicLinkHeader;

            tbDropBoxPublicParseResults.Clear();

            // handle parsing top-level files:
            // then recurse on all directories
            // and display all files, per directory
            if (rbParseRecursive.Checked)
            {
                RecursiveParse(DBoxFolderFiles, DBoxFolderDirectories);

                return;
            }

            // parse either top-level files only, or top-level directories only
            whatToParse = rbParseTopLevelFiles.Checked ? DBoxFolderFiles : DBoxFolderDirectories;

            foreach (string theFilePath in whatToParse)
            {
                rawLinkPath = DBoxPublicLinkHeader + theFilePath.Substring(startOfRawLink);
                rawLinkPath = rawLinkPath.Replace(oneSpace, replaceSpaceStr);
                tbDropBoxPublicParseResults.Text += rawLinkPath + newLine;
            }
        }

        private void RecursiveParse(string[] theFiles, string[] theDirectories)
        {

            foreach (string theFilePath in theFiles)
            {
                rawLinkPath = DBoxPublicLinkHeader + theFilePath.Substring(startOfRawLink);
                rawLinkPath = rawLinkPath.Replace(oneSpace, replaceSpaceStr);
                tbDropBoxPublicParseResults.Text += rawLinkPath + newLine;
            }

            foreach (string theDirectoryPath in theDirectories)
            {
                tbDropBoxPublicParseResults.Text += newLine 
                + "Directory: " 
                + theDirectoryPath 
                + " Total Files = " 
                + theFiles.Length.ToString()
                + newLine;

                RecursiveParse(Directory.GetFiles(theDirectoryPath), 
                Directory.GetDirectories(theDirectoryPath));
            }
        }
    }
}




这篇关于建议正确的工具来执行上下文菜单项或使用.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆