我有一个按钮,它将window.location设置为一个php文件,生成一个feed然后下载.但是,由于文件的大小因文件放入Feed而有所不同,因此从点击按钮到弹出的文件对话框有时需要一段时间.
我希望能够做的是单击按钮并显示loading.gif,直到对话框/文件完成.
任何想法都会很酷!
干杯
我在下面的test.php文件代码中调用jQuery"GET".
我正在尝试让脚本在生成的test.ini文件上弹出"另存为"对话框,以允许它在本地保存.但是,虽然我可以将结果回显给jQuery,但我似乎无法弹出"另存为"对话框.
更新:感谢下面的解决方案,我刚刚将$ .get更改为window.location.replace.
$('#test').click(
function()
{
//$.get('<?php echo get_bloginfo('template_directory') ?>/test.php');
window.location.replace("<?php echo get_bloginfo('template_directory') ?>/test.php");
}
);
Run Code Online (Sandbox Code Playgroud) 我目前正在从URL读取流.并将其保存为客户端上的文件.我知道Silverlight 4不支持SaveFileDialog上的默认文件名.
有没有人找到解决方法或某种方式将FileName注入流?
任何解决方法都可以很好地设置文件名.
码:
public void ClientOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
using (var file = Save.OpenFile())
{
CopyStream(e.Result, file);
}
}
public static void CopyStream(Stream input, Stream output)
{
var buffer = new byte[8 * 1024];
int length;
while ((length = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, length);
}
}
Run Code Online (Sandbox Code Playgroud) 如何仅使用"保存文件"对话框获取文件名?
MessageBox.Show("File was created with name: " + SOME CODE HERE +
Environment.NewLine + Environment.NewLine +
"You can find it at: " + Environment.NewLine + sfdNewFile.FileName);
Run Code Online (Sandbox Code Playgroud) 我想添加一个额外的提示,询问用户是否确定要保存文件,但仅限于某些"受保护"目录中的文件.假设我有一个file-needs-protection-p带文件名的函数,如果在保存该文件之前应该查询用户,则返回t.我怎样才能让Emacs问一些"This file is protected. Are you sure you want to modify it?"用户试图保存这样一个文件的内容,然后让Emacs在用户回答no时中止保存?
希望有一些特殊的钩子,我可以添加一个使用的函数,yes-or-no-p如果函数返回false,Emacs将中止保存?
我试着告诉你我的问题。ClosedXML我有方法SaveAs(),但是当我使用时SaveAs(string name),它将我的Excel文档保存到一些带有奇怪路径的奇怪文件夹中。所以我决定让savefiledialog用户可以选择文档的文件夹和名称。我该如何使用savefiledialogwith closedXML?
SaveAs()也有SaveAs(Path path)。我可以使用它吗?
我已经看过几次这个问题,但没有回答对我有任何帮助.我希望保存对话框使用JFileChooser建议像"myFile.txt"这样的文件名.
继承人我所拥有的:
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setCurrentDirectory(new File("C:\\"));
jFileChooser.showSaveDialog(null);
Run Code Online (Sandbox Code Playgroud) 我试图将SaveFileDialog添加到Windows应用程序中,在其中我从多行文本框的内容中保存了一个简单的文本文件。该程序似乎可以正常工作,直到保存对话框,并且我没有收到任何错误,但是一旦单击“保存”按钮,应用程序就会挂起。唯一的解决方法是单击“停止调试”按钮。这是我尝试过的代码段,但是都创建了相同的挂起:
private void button_SaveToFile_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
File.WriteAllText(saveFileDialog1.FileName, textBox_ListDestination.Text);
}
}
Run Code Online (Sandbox Code Playgroud)
和
private void button_SaveToFile_Click(object sender, EventArgs e)
{
Stream myStream;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((myStream = saveFileDialog1.OpenFile()) != null)
{
File.WriteAllText(saveFileDialog1.FileName, textBox_ListDestination.Text);
myStream.Close();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个按钮,打开一个保存对话框窗口,其中设置了默认扩展过滤器.当我保存文件时,它会在正确的文件夹中创建它,但它不会在末尾添加扩展名.如何根据过滤器将扩展名添加到文件末尾?这是我的保存文件按钮代码:
btnNewButton = new JButton("Export File");
btnNewButton.addActionListener (new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
final JFileChooser finder = new JFileChooser();
finder.setFileFilter(new FileNameExtensionFilter("Board Files", "boa"));
int returnVal = finder.showSaveDialog(null);
if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
java.io.File file = finder.getSelectedFile();
String file_name = file.toString();
JOptionPane.showMessageDialog(null, file_name);
WriteFile data = new WriteFile(file_name);
try {
data.writeToFile("Testing 1");
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
});
Run Code Online (Sandbox Code Playgroud) 我有一个带有链接的 Web 应用程序。单击此链接时,它会打开弹出窗口,要求使用特定应用程序打开文件。
我编写了以下代码来创建 firefox 配置文件,它适用于其他文件扩展名,但不适用于 .xlsx 文件。
profile.setEnableNativeEvents(true);
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.dir", System.getProperty("user.dir")+"\\src\\com\\Download");
profile.setPreference("browser.download.downloadDir", System.getProperty("user.dir")+"\\src\\com\\Download");
profile.setPreference("browser.download.defaultFolder", System.getProperty("user.dir")+"\\src\\com\\Download");
profile.setPreference("browser.download.manager.closeWhenDone", true);
profile.setPreference("pdfjs.disabled", true);
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/xls, application/zip,text/csv,application/msword,application/excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/pdf," +
"application/vnd.ms-excel,application/msword,application/unknown,application/vnd.openxmlformats-officedocument.wordprocessingml.document");
Run Code Online (Sandbox Code Playgroud)
savefiledialog ×10
c# ×3
java ×3
jfilechooser ×2
swing ×2
elisp ×1
emacs ×1
excel ×1
filenames ×1
firefox ×1
get ×1
javascript ×1
jquery ×1
path ×1
php ×1
popupwindow ×1
save ×1
silverlight ×1
winforms ×1